[gdal-dev] SHP support in GDAL vs. GDAL-OGR
ben at v...
Tue Jan 15 04:09:23 EST 2002
> > 2. Try to modify the export status of shapelib in GDAL (as above,
> > perhaps there is some way to fix it)
> Looking in the makefile.vc for Shapelib, it does this:
Unfortunately that does not get the symbols exposed in the DLL - that is
fine for Shapelib, only because Shapelib is being built and linked
statically. To be exposed in a DLL, the functions must be declared as
The remaining trouble has to do with this macro in shapelib.h:
#define SHPAPI_CALL1(x) * SHPAPI_CALL
This is a puzzling macro, which does not use its argument (why have it?).
It also prevents setting SHPAPI_CALL=__declspec(dllexport) since __declspec
must appear *before* the asterisk, not after.
So, in the file:
EXTRAFLAGS = -I.. -I..\.. /DSHPAPI_CALL=__declspec(dllexport)
and in shapelib.h, i changed the macro to be:
#define SHPAPI_CALL1(x) SHPAPI_CALL *
(Note asterisk after, rather than before.) This makes everything work
nicely for the GDAL DLL. However...
I tried setting it to /DSHPAPI_CALL=__stdcall, and it was *not* happy.
Apparently __stdcall must come after the asterisk, whereas __declspec must
I guess the only complete solution here would be to have two macros, e.g.
SHPAPI_CALL1, SHPAPI_CALL2 which would come before and after the asterisk.
Not very pretty, but it would handle all cases. If you'd like me to do that
and submit it, i'd be glad to.
In the meantime, i am *very* happy that i am now able to build GDAL in a way
that i can use shapelib.
More information about the Gdal-dev