[geos-devel] Using the GEOS C++ interface on Windows (Visual Studio)

Ragi Y. Burhum ragi at burhum.com
Thu Mar 19 16:23:23 EDT 2009


Hello,

For about six months now, we (the company I am working for) have been
using the GEOS C++ API on Linux and Mac platforms without a problem
for an application we are writing. Last week, we started porting that
application to Windows (Visual Studio IDE) and when it came down to
linking I realized that only the GEOS C API had the GEOS_DLL contructs
to export the symbols.

#if defined(_MSC_VER)
#  define GEOS_DLL     __declspec(dllexport)
#else
#  define GEOS_DLL
#endif

So to fix that. These are the changed that were made:

1.- Refactored the GEOS_DLL preprocessor out of geos_c.h.in and put it
in a new file Export.h

#if defined(_MSC_VER) || defined(__CYGWIN__) || defined(__MINGW32__)
|| defined( __BCPLUSPLUS__)  || defined( __MWERKS__)
    #  if defined( GEOS_LIBRARY_STATIC )
    #    define GEOS_DLL
    #  elif defined( GEOS_LIBRARY_DLL)
    #    define GEOS_DLL   __declspec(dllexport)
    #  else
    #    define GEOS_DLL   __declspec(dllimport)
    #  endif
#else
    #  define GEOS_DLL
#endif

2.- Some regular expression magic along with manual edits to make all
the C++ classes (as well as some structs) include a GEOS_DLL construct

3.- define GEOS_LIBRARY_DLL / GEOS_LIBRARY in the right VS projects.

That seemed to do the trick.

The changes were made on 3.0.3 but I was wondering if there was some
interest on pushing this upstream to you guys.

Thanks,

- Ragi


More information about the geos-devel mailing list