Building GDAL for Windows
GDAL is great! Except that binary distributions of it for Windows are either hard to find or too far behind the times. I had to build it myself to be used in velocipy (my sound velocity analysis program). Here are the notes of what I had to do to build it.
I tried a variety of different compilers and eventually realized that I had to use the same compiler that Python2.5 was built with. That turned out to be MS Visual Studio 7 (.net 2003).
Edit the nmake.opt file:
diff nmake.opt.orig nmake.opt 8c8 < GDAL_HOME = "C:\warmerda\bld" --- > GDAL_HOME = "C:\dev\src\gdal-1.4.3" 20c20 < PYDIR = "C:\Software\Python24" --- > PYDIR = "C:\dev\src\Python-2.5.1" 25c25 < SWIG = swig.exe --- > SWIG = "C:\Program Files\swig\swig.exe" 34c34 < MSVC_VER=1310 --- > MSVC_VER=1400 69c69 < VCDIR = D:\Software\VStudio\VC98 --- > VCDIR = "C:\Program Files\Microsoft Visual Studio 8\VC" 151,156c151,156 < #MRSID_DIR = d:\projects\mrsid < #MRSID_INCLUDE = -I$(MRSID_DIR)\include\base -I$(MRSID_DIR)\include\support \ < # -I$(MRSID_DIR)\include\metadata \ < # -I$(MRSID_DIR)\include\mrsid_readers \ < # -I$(MRSID_DIR)\include\j2k_readers < #MRSID_LIB = $(MRSID_DIR)\lib\Release_md\lti_dsdk_dll.lib advapi32.lib user32.lib --- > MRSID_DIR = "C:\dev\src\LizardTechSDKs\Geo_DSDK-6.0.7.1407" > MRSID_INCLUDE = -I$(MRSID_DIR)\include\base -I$(MRSID_DIR)\include\support > \ > -I$(MRSID_DIR)\include\metadata \ > -I$(MRSID_DIR)\include\mrsid_readers \ > -I$(MRSID_DIR)\include\j2k_readers > MRSID_LIB = $(MRSID_DIR)\lib\Release_md\lti_dsdk_dll.lib advapi32.lib user32.lib
At some point on an earlier build, the compiler couldn't fild snprintf nor copysign[f], so I had to do the following, editing port/cpl_config.h. But I can't remember whether it affected this build:
diff cpl_config.h.orig cpl_config.h 17c17 < #define HAVE_COPYSIGN 1 --- > /*#define HAVE_COPYSIGN 1*/ 20c20 < #define HAVE_COPYSIGNF 1 --- > /*#define HAVE_COPYSIGNF 1*/ 109c109 < #define HAVE_SNPRINTF 1 --- > /*#define HAVE_SNPRINTF 1*/
I did this at one point too
$ diff port/cpl_config.h.vc~ port/cpl_config.h.vc 14c14 < #define HAVE_VPRINTF 1 --- > #define HAVE_VPRINTF 0
Build it:
PATH=%PATH%;"C:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\bin\" vcvars32.bat nmake clean nmake /f makefile.vc nmake /f makefile.vc install
Ooops, I forgot GEOS, so I went back and did that:
build geos-svn (rev 2129)
svn co http://svn.osgeo.org/geos/ A few header files are not exactly there... cp platform.h.vc platform.h cp version.h.vc version.h cp capi/geos_c.h.in capi/geos_c.h nmake -f source/Makefile.vc
Builds cleanly. Go back to GDAL land. Edit the nmake.opts files:
< GEOS_DIR=C:/dev/src/geos-svn/trunk < GEOS_CFLAGS = -I$(GEOS_DIR)/capi -I$(GEOS_DIR)/source/headers -DHAVE_GEOS < GEOS_LIB = $(GEOS_DIR)/source/geos_c_i.lib --- > #GEOS_DIR=C:/warmerda/geos > #GEOS_CFLAGS = -I$(GEOS_DIR)/capi -I$(GEOS_DIR)/source/headers -DHAVE_GEOS > #GEOS_LIB = $(GEOS_DIR)/source/geos_c_i.lib
nmake... builds clean. Yay! Now just do the install:
cp gdal15.dll pymod cp GEOS_DIR/source/geos_c.dll pymod
...and then copy the pymod dir over to PYTHON_DIR/site-packages. I think that that's it. At least that all that I can remember from my notes and memory of a year ago.
blog comments powered by Disqus