[gdal-dev] Fixes for nmake.opt and makefile.vc
Ben Discoe
ben at vterrain.org
Sat Nov 10 21:28:01 PST 2012
I needed to build GDAL on WIndows again this evening, so I grabbed the
latest gdal192.zip.
For years (like, 12 years) I have tried maintaining GDAL MSVC project files,
but that isn't a fun task.
So instead, I figured I'd give the makefile.vc a try.
It does not appear to be in a state that's usable to compile other software
on top of GDAL in both debug and release.
1. nmake.opt does not put debug and release executables in separate folders.
This is essential. So, I did this:
BINDIR = $(GDAL_HOME)\bin
------>
!IFNDEF DEBUG
BINDIR = $(GDAL_HOME)\bin-release
!ELSE
BINDIR = $(GDAL_HOME)\bin-debug
!ENDIF
2. nmake.opt does not name the debug and release libraries or DLL
differently. This is also essential; you simply cannot mix debug and
non-debug with MSVC. So I did the following:
GDAL_DLL = gdal$(VERSION).dll
------>
!IFNDEF DEBUG
GDAL_DLL = gdal$(VERSION)-vc10.dll
!ELSE
GDAL_DLL = gdal$(VERSION)d-vc10.dll
!ENDIF
And:
GDALLIB = $(GDAL_ROOT)/gdal_i.lib
------>
!IFNDEF DEBUG
GDALLIB = $(GDAL_ROOT)\gdal_i-vc10.lib
!ELSE
GDALLIB = $(GDAL_ROOT)\gdal_id-vc10.lib
!ENDIF
Note the forward slash changed to a backslash. The forward slash causes
"make devinstall" fail later if not fixed. The "-vc10" is optional, but
those of us who build for more than one compiler version need it, because
once again, you cannot mix binaries between versions of MSVC, so to avoid
confusion and crashes, it's vital to put the flavor in the filename.
3. There are places in ./makefile.vc which hard-code the name of the import
library instead of using the definition from nmake.opt. I fixed these:
if exist gdal_i.lib del gdal_i.*
---------->
if exist $(GDALLIB) del gdal_i*.*
/out:$(GDAL_DLL) /implib:gdal_i.lib
$(LINKER_FLAGS)
---------->
/out:$(GDAL_DLL) /implib:$(GDALLIB)
$(LINKER_FLAGS)
copy gdal_i.lib $(LIBDIR)
---------->
copy $(GDALLIB) $(LIBDIR)
4. And one more place, in ./apps/makefile.vc, the line:
LIBS = $(GDAL_ROOT)\gdal_i.lib
Must be moved down after the !INCLUDE and changed to:
LIBS = $(GDALLIB)
4. I'm leaving alone the issue with /MD and /MDd. I see it's been discussed
before, and the above fixes are important whether you use /MDd or not.
With those changes, I was able to use the command-line to give 4 commands:
nmake -f makefile.vc DEBUG=1
nmake -f makefile.vc DEBUG=1 devinstall
nmake -f makefile.vc
nmake -f makefile.vc devinstall
..which built and installed both debug and release versions of GDAL
successfully.
I guess since this has been broken for a while, people have simply either
just building release, and/or just the GDAL executables (not the devinstall
target).
-Ben
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/gdal-dev/attachments/20121110/ddb1bd60/attachment.html>
More information about the gdal-dev
mailing list