[geos-devel] automake/conf/aclocal

David Blasby dblasby at refractions.net
Mon Apr 7 16:00:21 EDT 2003

I tried again on a different linux machine here, unfortunately with the 
same wrong results.

[dblasby at lion work_dave]$ rm *.o test
[dblasby at lion work_dave]$ ./make_it
geom text (to be parsed norman):POLYGON((100 200,100 140,180 140,180 
200,100 200))

geom (WKTWriter):POLYGON ((100.0000000000000000 200.0000000000000000, 
100.0000000000000000 140.00000000
00000000, 180.0000000000000000 140.0000000000000000, 
180.0000000000000000 200.0000000000000000, 100.000
0000000000000 200.0000000000000000))

result in C (norman) is
POLYGON ((100.0000000000000000 200.0000000000000000, 
100.0000000000000000 140.0000000000000000, inf inf
, inf inf, inf inf))
[dblasby at lion work_dave]$ cat make_it


g++ -I${HEADERS} -c test_cpp.cpp
gcc -I./ -o test test.c test_cpp.o -L${LIBS} -lgeos -lstdc++

[dblasby at lion work_dave]$ cat test_cpp.cpp
// g++ -g test.cpp -c -I/usr/local/include/geos

#include <string>
#include <iostream>
#include <fstream>

#include "io.h"
#include "geos_api.h"

char *GEOSasText(GeometryWrapper g)
        Geometry *g1 = (Geometry *)g;

        WKTWriter *w=new WKTWriter();

        string s = w->write(g1);

        char *result = (char *)s.c_str();

        return result ;

GeometryWrapper createGEOSFromText(char *wkt)
        cout  <<"geom text (to be parsed norman):"<< wkt << endl;

    Geometry *g = new Geometry;
        WKTReader *r = new WKTReader(new GeometryFactory(new

        g = r->read(wkt);

        WKTWriter *w=new WKTWriter();

    cout << endl << "geom (WKTWriter):"<< w->write(g) << endl;

        delete r;
    delete w;
        return (GeometryWrapper)g;

[dblasby at lion work_dave]$ cat test.c
//c++ -c test_cpp.cpp
//gcc -g -o test test.c test_cpp.o -lm -lgeos -lstdc++

#include "stdio.h"
#include "geos_api.h"

extern    GeometryWrapper createGEOSFromText(char *wkt);
extern    char * GEOSasText(GeometryWrapper g1);

int main(int argC, char* argV[])
                        GeometryWrapper g =
createGEOSFromText("POLYGON((100 200,100 140,180 140,180 200,100 200))");

                        printf("\nresult in C (norman) is

[dblasby at lion work_dave]$ cat geos_api.h
#ifdef __cplusplus
#  define GEOS_C_START           extern "C" {
#  define GEOS_C_END             }
#  define GEOS_C_START
#  define GEOS_C_END


typedef void *GeometryWrapper;

GeometryWrapper createGEOSFromText(char *wkt);
char * GEOSasText(GeometryWrapper g1);



[dblasby at lion work_dave]$ ldd test
        libgeos.so.1 => /usr/local/lib/libgeos.so.1 (0x40027000)
        libstdc++-libc6.2-2.so.3 => /usr/lib/libstdc++-libc6.2-2.so.3 
        libc.so.6 => /lib/libc.so.6 (0x4011b000)
        libm.so.6 => /lib/libm.so.6 (0x40242000)
        /lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x40000000)
[dblasby at lion work_dave]$ gcc --version
[dblasby at lion work_dave]$ g++ --version
[dblasby at lion work_dave]$ ld --version
GNU ld version 20020207
Copyright 2002 Free Software Foundation, Inc.
This program is free software; you may redistribute it under the terms of
the GNU General Public License.  This program has absolutely no warranty.
[dblasby at lion work_dave]$ libtool --version
ltmain.sh (GNU libtool) 1.4.3 (1.922.2.110 2002/10/23 01:39:54)
[dblasby at lion work_dave]$ ldd /usr/local/lib/libgeos.so
        libc.so.6 => /lib/libc.so.6 (0x400c4000)
        /lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x80000000)

More information about the geos-devel mailing list