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

Roger Bivand Roger.Bivand at nhh.no
Wed Feb 15 13:05:29 EST 2006


On Wed, 15 Feb 2006, Frank Warmerdam wrote:

> 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?

Frank,

The linker says 7.10, so I guess it must be something like that.

My current work-around is to wrap calls to C++ versions of the unfound 
functions in extern "C" {} in a file named *.cpp - seems to find the files 
under Windows, I'll check that I can back-fit to gcc/g++ under Linux. I'll 
try that first and report back, and fall back on your suggestion if I'm 
not lucky.

Thanks for getting back so fast!

Roger

> 
> 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,
> 

-- 
Roger Bivand
Economic Geography Section, Department of Economics, Norwegian School of
Economics and Business Administration, Helleveien 30, N-5045 Bergen,
Norway. voice: +47 55 95 93 55; fax +47 55 95 95 43
e-mail: Roger.Bivand at nhh.no




More information about the Gdal-dev mailing list