[gdal-dev] Problem compiling osgeo._gdal_array Python module under MinGW

luper rouch luper.rouch at gmail.com
Tue Jun 15 20:47:45 EDT 2010


Hi,

The GDAL Python bindings fails to build under MinGW with an error
about sprintf() being defined twice in stdio.h and libmsvcr90.a.

This happens while building the osgeo._gdal_array module, which is
only built if numpy is installed on the system.

The solution I found was to define the "__USE_MINGW_ANSI_STDIO" macro,
which forces using the MinGW's versions of *printf(). Edit
"swig/python/setup.py" and change the "array_module" extension
definition to this:

array_module = Extension('osgeo._gdal_array',
                 sources=['extensions/gdal_array_wrap.cpp'],
                 extra_compile_args=["-D __USE_MINGW_ANSI_STDIO"],
                 extra_link_args=extra_link_args)

There are other quirks for building GDAL from source on win32/MinGW, I
wrote a note about it:

http://essnerr.blogspot.com/2010/06/building-my-python-toolchain-with-mingw.html

Cheers,
--
Lup


More information about the gdal-dev mailing list