[gdal-dev] Re: Link GDAL with MinGW
lucafasano at interfree.it
Thu Feb 26 12:08:51 EST 2009
Frank Warmerdam <warmerdam <at> pobox.com> writes:
> Ari Jolma wrote:
> > oops, I believe it is not correct to say "Swig bindings use some C++
> > API", but it is nevertheless sometimes hard/not possible to mix VC and
> > MinGW when developing for Windows
> I am interested in making use of the GDAL and OGR C API practical and even
> convenient when GDAL is built with MSVC and applications are built with
> MinGW. If there is a particular problem with this, I would encourage
> filing a ticket.
> Best regards,
First of all, thanks to your fast answers.
Then, I report following my makefile.
CPPFLAGS:=-Wall -fPIC $(GDAL_INCLUDE) $(CPPFLAGS) $(HDF5_INCLUDE)
CPPFLAGS:= -DWIN32 -DDLL_EXPORT -DPIC $(CPPFLAGS)
# Comment out for release mode
CPPFLAGS:=-g3 -ggdb3 -DDEBUG $(CPPFLAGS)
LNK_FLAGS:=$(LNK_FLAGS) -L "C:\gdalwin32-1.6_bin\bin"
#both msvcr inserted 71 and 90
LNK_FLAGS:=$(LNK_FLAGS) -lgdal16 -lmsvcr71 -lmsvcr91
LNK_FLAGS:=$(LNK_FLAGS) -L "C:\5-168-win-vnet_corrected_for_MinGW\dll"
LNK_FLAGS:=$(LNK_FLAGS) -lhdf5_cppdll -lhdf5dll -lhdf5_hldll
.PHONY: default plugin clean
PLUGIN = gdal_HDF5.so
rm -f *.o *~ $(PLUGIN)
$(LD_SHARED) $(OBJ) $(LNK_FLAGS) -o $
When I compile my code with MinGW it's all OK, but when MinGW starts
linking it doesn't found all methods of GDALDataset giving me "undefined
reference" to them. It seems not to link gdal dll.
You can try it in gdalsrc/frmts/hdf5 because it needs three source files in this
PS. To avoid compiling errors I re-compiled hdf5 as described here:
http://lists.osgeo.org/pipermail/gdal-dev/2007-April/012825.html and modified
/hdf5/include/H5pubconf.h defining H5_SIZEOF_SSIZE_T:
#define H5_SIZEOF_SSIZE_T 4 /* for 32 bit machines */
(as described here
PS2. I tried to convert gdal dll into a .a file for MinGW as described here:
http://www.mingw.org/wiki/MSVC_and_MinGW_DLLs but it doesn-t link correctly.
More information about the gdal-dev