[Gdal-dev] Windows linking to FWTools gdal_i.lib

Frank Warmerdam warmerdam at pobox.com
Wed Feb 15 12:51:54 EST 2006


Roger Bivand wrote:
> In revising and extending the R GDAL bindings, I'm using VC++ (cl) under 
> Windows on C API files. On Linux (GDAL 1.3.1) the references to:
> 
> OSRNewSpatialReference
> OSRDestroySpatialReference
> OSRExportToProj4
> OSRExportToWkt
> 
> are found and work, but give error LNK2019 in the Windows linking step
> when building the rgdal shared object, using Windows binary
> FWTools1.0.0.7a gdal_i.lib. The LNK2019 error message prepends an
> underscore to the function names. Curiously, it does not report that other
> OSR* functions are not found in this function:

Roger,

The problem is that some (but not by any means all) C entry points in
OGR, OSR and GDAL are exported with standard call conventions for easier
use from Pascal and VB6.  If you look in ogr_srs_api.h you will see the
CPL_STDCALL attribute applied to some functions.

What is less clear to me is why your compiler isn't already adjusting
the calls to use stdcall conventions too.   When compiling with a
Microsoft compiler and not explicitly defining -DCPL_DISABLE_STDCALL
the CPL_STDCALL macro should be expanded to __stdcall and thus the
application should also know to call the functions with stdcall
conventions.

You are building with VC6, VC7 or VC7.1, right?

You might want to try and determine if CPL_STDCALL is properly being
defined as __stdcall in cpl_port.h (called from ogr_srs_api.h).

Best regards,
-- 
---------------------------------------+--------------------------------------
I set the clouds in motion - turn up   | Frank Warmerdam, warmerdam at pobox.com
light and sound - activate the windows | http://pobox.com/~warmerdam
and watch the world go round - Rush    | Geospatial Programmer for Rent




More information about the Gdal-dev mailing list