<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40"><head><meta http-equiv=Content-Type content="text/html; charset=us-ascii"><meta name=Generator content="Microsoft Word 14 (filtered medium)"><style><!--
/* Font Definitions */
@font-face
{font-family:"Cambria Math";
panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
{font-family:Calibri;
panose-1:2 15 5 2 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0in;
margin-bottom:.0001pt;
font-size:11.0pt;
font-family:"Calibri","sans-serif";}
a:link, span.MsoHyperlink
{mso-style-priority:99;
color:blue;
text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
{mso-style-priority:99;
color:purple;
text-decoration:underline;}
span.EmailStyle17
{mso-style-type:personal-compose;
font-family:"Calibri","sans-serif";
color:windowtext;}
.MsoChpDefault
{mso-style-type:export-only;
font-family:"Calibri","sans-serif";}
@page WordSection1
{size:8.5in 11.0in;
margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
{page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]--></head><body lang=EN-US link=blue vlink=purple><div class=WordSection1><p class=MsoNormal>I needed to build GDAL on WIndows again this evening, so I grabbed the latest gdal192.zip.<o:p></o:p></p><p class=MsoNormal>For years (like, 12 years) I have tried maintaining GDAL MSVC project files, but that isn't a fun task.<o:p></o:p></p><p class=MsoNormal>So instead, I figured I'd give the makefile.vc a try.<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>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.<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>1. nmake.opt does not put debug and release executables in separate folders. This is essential. So, I did this:<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>BINDIR = $(GDAL_HOME)\bin<o:p></o:p></p><p class=MsoNormal>------><o:p></o:p></p><p class=MsoNormal>!IFNDEF DEBUG<o:p></o:p></p><p class=MsoNormal>BINDIR = $(GDAL_HOME)\bin-release<o:p></o:p></p><p class=MsoNormal>!ELSE<o:p></o:p></p><p class=MsoNormal>BINDIR = $(GDAL_HOME)\bin-debug<o:p></o:p></p><p class=MsoNormal>!ENDIF<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>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:<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>GDAL_DLL = gdal$(VERSION).dll<o:p></o:p></p><p class=MsoNormal>------><o:p></o:p></p><p class=MsoNormal>!IFNDEF DEBUG<o:p></o:p></p><p class=MsoNormal>GDAL_DLL = gdal$(VERSION)-vc10.dll<o:p></o:p></p><p class=MsoNormal>!ELSE<o:p></o:p></p><p class=MsoNormal>GDAL_DLL = gdal$(VERSION)d-vc10.dll<o:p></o:p></p><p class=MsoNormal>!ENDIF<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>And:<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>GDALLIB = $(GDAL_ROOT)/gdal_i.lib<o:p></o:p></p><p class=MsoNormal>------><o:p></o:p></p><p class=MsoNormal>!IFNDEF DEBUG<o:p></o:p></p><p class=MsoNormal>GDALLIB = $(GDAL_ROOT)\gdal_i-vc10.lib<o:p></o:p></p><p class=MsoNormal>!ELSE<o:p></o:p></p><p class=MsoNormal>GDALLIB = $(GDAL_ROOT)\gdal_id-vc10.lib<o:p></o:p></p><p class=MsoNormal>!ENDIF<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>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.<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>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:<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal> if exist gdal_i.lib del gdal_i.*<o:p></o:p></p><p class=MsoNormal>----------><o:p></o:p></p><p class=MsoNormal> if exist $(GDALLIB) del gdal_i*.*<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal> /out:$(GDAL_DLL) /implib:gdal_i.lib $(LINKER_FLAGS)<o:p></o:p></p><p class=MsoNormal>----------><o:p></o:p></p><p class=MsoNormal> /out:$(GDAL_DLL) /implib:$(GDALLIB) $(LINKER_FLAGS)<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal> copy gdal_i.lib $(LIBDIR)<o:p></o:p></p><p class=MsoNormal>----------><o:p></o:p></p><p class=MsoNormal> copy $(GDALLIB) $(LIBDIR)<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>4. And one more place, in ./apps/makefile.vc, the line:<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>LIBS = $(GDAL_ROOT)\gdal_i.lib<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>Must be moved down after the !INCLUDE and changed to:<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>LIBS = $(GDALLIB)<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>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.<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>With those changes, I was able to use the command-line to give 4 commands:<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>nmake -f makefile.vc DEBUG=1<o:p></o:p></p><p class=MsoNormal>nmake -f makefile.vc DEBUG=1 devinstall<o:p></o:p></p><p class=MsoNormal>nmake -f makefile.vc<o:p></o:p></p><p class=MsoNormal>nmake -f makefile.vc devinstall<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>..which built and installed both debug and release versions of GDAL successfully.<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>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).<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>-Ben<o:p></o:p></p></div></body></html>