[gdal-dev] building gdal on msvc with external zlib
Rashad M
mohammedrashadkm at gmail.com
Tue Feb 3 06:32:19 PST 2015
On Tue, Feb 3, 2015 at 9:47 AM, Even Rouault <even.rouault at spatialys.com>
wrote:
> Le mardi 03 février 2015 08:02:58, Rashad M a écrit :
> > Hello,
> >
> > Is it possible to use existing libz when building gdal on msvc. On linux
> I
> > can pass --with-libz= during configure. But on windows I couldn't find
> any
> > options in the be-alike nmake.opt
> >
> > Also in gdal/port/Makefile.vc there is zlib includes in EXTRAFLAGS which
> > points to internal zlib from frmts/zlib
> >
> > Is there any reason I must you internal zlib with windows?
>
> Rashad,
>
> indeed it seems the option has never been implemented. I cannot think of a
> particular reason why linking against external zlib wouldn't work. This
> would
> require mostly editing the relevant makefiles (the one you mention and
> other
> ones such as in frmts/gtiff/libtiff etc...).
>
Ok. Here is a patch attached that can use external zlib when compiling gdal
on windows.
Could you have a look at it and let me if anything missing.
I made the diff against 1.11 branch. below is svn info output
Chemin : .
Chemin racine de la copie de travail : C:\Temp\gdal
URL : http://svn.osgeo.org/gdal/branches/1.11/gdal
Racine du dépôt : http://svn.osgeo.org/gdal
UUID du dépôt : f0d54148-0727-0410-94bb-9a71ac55c965
Révision : 28405
Type de noud : répertoire
Tâche programmée : normale
Auteur de la dernière modification : tamas
Révision de la dernière modification : 28397
Date de la dernière modification: 2015-01-31 23:34:06 +0100 (sam. 31 janv.
2015)
Even
>
> >
> > [1] http://svn.osgeo.org/gdal/trunk/gdal/port/makefile.vc
> > [2] http://svn.osgeo.org/gdal/trunk/gdal/nmake.opt
>
> --
> Spatialys - Geospatial professional services
> http://www.spatialys.com
>
--
Regards,
Rashad
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/gdal-dev/attachments/20150203/88c4be37/attachment-0001.html>
-------------- next part --------------
Index: nmake.opt
===================================================================
--- nmake.opt (r�vision 28405)
+++ nmake.opt (copie de travail)
@@ -228,6 +228,11 @@
#JPEGDIR = c:/projects/jpeg-6b
#JPEG_LIB = $(JPEGDIR)/libjpeg.lib
+#if using an external zlib library uncomment the follwing lines
+#ZLIB_EXTERNAL_LIB = 1
+#ZLIB_INC = -IC:\zlib_install\include
+#ZLIB_LIB = C:\zlib_install\lib\zlib.lib
+
#if using an external png library uncomment the follwing lines
#PNG_EXTERNAL_LIB = 1
#PNGDIR = c:/projects/libpng-1.0.8
@@ -591,6 +596,14 @@
INC = -I$(GDAL_ROOT)\port -I$(GDAL_ROOT)\ogr -I$(GDAL_ROOT)\gcore \
-I$(GDAL_ROOT)\alg -I$(GDAL_ROOT)\ogr\ogrsf_frmts
+!IFDEF ZLIB_EXTERNAL_LIB
+ZLIB_CFLAGS = $(ZLIB_INC)
+ZLIB_LFLAGS = $(ZLIB_LIB)
+!ELSE
+ZLIB_CFLAGS = -I$(GDAL_ROOT)\frmts\zlib
+ZLIB_LFLAGS = $(GDAL_ROOT)/frmts/zlib/*.obj
+!ENDIF
+
!IFDEF MSVC_VLD_DIR
MSVC_VLD_FLAGS=-DMSVC_USE_VLD=1 -I$(MSVC_VLD_DIR)\include
!IFDEF WIN64
Index: frmts/png/makefile.vc
===================================================================
--- frmts/png/makefile.vc (r�vision 28405)
+++ frmts/png/makefile.vc (copie de travail)
@@ -4,12 +4,10 @@
OBJ = \
pngdataset.obj
-
-#EXTRAFLAGS = -I..\zlib -Ilibpng
!IFDEF PNG_EXTERNAL_LIB
-EXTRAFLAGS = -I..\zlib -I$(PNGDIR)
+EXTRAFLAGS = $(ZLIB_CFLAGS) -I$(PNGDIR)
!ELSE
-EXTRAFLAGS = -I..\zlib -Ilibpng
+EXTRAFLAGS = $(ZLIB_CFLAGS) -Ilibpng
!ENDIF
default: $(OBJ)
Index: frmts/png/libpng/makefile.vc
===================================================================
--- frmts/png/libpng/makefile.vc (r�vision 28405)
+++ frmts/png/libpng/makefile.vc (copie de travail)
@@ -23,10 +23,11 @@
GDAL_ROOT = ..\..\..
-EXTRAFLAGS = -I..\..\zlib
-
!INCLUDE $(GDAL_ROOT)\nmake.opt
+EXTRAFLAGS = $(ZLIB_CFLAGS)
+
+
default: $(OBJ)
xcopy /D /Y *.obj ..\..\o
Index: frmts/gtiff/libtiff/makefile.vc
===================================================================
--- frmts/gtiff/libtiff/makefile.vc (r�vision 28405)
+++ frmts/gtiff/libtiff/makefile.vc (copie de travail)
@@ -41,7 +41,7 @@
GDAL_ROOT = ..\..\..
-EXTRAFLAGS = -I..\..\zlib -DZIP_SUPPORT -DPIXARLOG_SUPPORT \
+EXTRAFLAGS = $(ZLIB_CFLAGS) -DZIP_SUPPORT -DPIXARLOG_SUPPORT \
$(JPEG_FLAGS) $(JPEG12_FLAGS) $(LZMA_FLAGS) \
$(SOFTWARNFLAGS)
Index: frmts/ozi/makefile.vc
===================================================================
--- frmts/ozi/makefile.vc (r�vision 28405)
+++ frmts/ozi/makefile.vc (copie de travail)
@@ -5,7 +5,7 @@
!INCLUDE $(GDAL_ROOT)\nmake.opt
-EXTRAFLAGS = -I..\zlib
+EXTRAFLAGS = $(ZLIB_CFLAGS)
default: $(OBJ)
xcopy /D /Y *.obj ..\o
Index: frmts/iso8211/makefile.vc
===================================================================
--- frmts/iso8211/makefile.vc (r�vision 28405)
+++ frmts/iso8211/makefile.vc (copie de travail)
@@ -21,22 +21,22 @@
all: default 8211view.exe 8211dump.exe 8211createfromxml.exe
iso8211.dll: $(OBJ) $(CPLLIB)
- link /dll $(LDEBUG) $(OBJ) $(CPLLIB) ../zlib/*.obj \
+ link /dll $(LDEBUG) $(OBJ) $(CPLLIB) $(ZLIB_LFLAGS) \
/out:iso8211.dll /implib:iso8211_i.lib
if exist $@.manifest mt -manifest $@.manifest -outputresource:$@;1
8211view.exe: 8211view.obj $(OBJ) $(CPLLIB)
- $(CC) $(CFLAGS) 8211view.obj $(OBJ) $(CPLLIB) $(LIBICONV_LIBRARY) $(CURL_LIB) ../zlib/*.obj /link $(LINKER_FLAGS)
+ $(CC) $(CFLAGS) 8211view.obj $(OBJ) $(CPLLIB) $(LIBICONV_LIBRARY) $(CURL_LIB) $(ZLIB_LFLAGS) /link $(LINKER_FLAGS)
if exist $@.manifest mt -manifest $@.manifest -outputresource:$@;1
del 8211view.obj
8211dump.exe: 8211dump.obj $(OBJ) $(CPLLIB)
- $(CC) $(CFLAGS) 8211dump.obj $(OBJ) $(CPLLIB) $(LIBICONV_LIBRARY) $(CURL_LIB) ../zlib/*.obj /link $(LINKER_FLAGS)
+ $(CC) $(CFLAGS) 8211dump.obj $(OBJ) $(CPLLIB) $(LIBICONV_LIBRARY) $(CURL_LIB) $(ZLIB_LFLAGS) /link $(LINKER_FLAGS)
if exist $@.manifest mt -manifest $@.manifest -outputresource:$@;1
del 8211dump.obj
8211createfromxml.exe: 8211createfromxml.obj $(OBJ) $(CPLLIB)
- $(CC) $(CFLAGS) 8211createfromxml.obj $(OBJ) $(CPLLIB) $(LIBICONV_LIBRARY) $(CURL_LIB) ../zlib/*.obj /link $(LINKER_FLAGS)
+ $(CC) $(CFLAGS) 8211createfromxml.obj $(OBJ) $(CPLLIB) $(LIBICONV_LIBRARY) $(CURL_LIB) $(ZLIB_LFLAGS) /link $(LINKER_FLAGS)
if exist $@.manifest mt -manifest $@.manifest -outputresource:$@;1
del 8211createfromxml.obj
Index: frmts/grib/makefile.vc
===================================================================
--- frmts/grib/makefile.vc (r�vision 28405)
+++ frmts/grib/makefile.vc (copie de travail)
@@ -29,4 +29,4 @@
gdal_GRIB.dll: default
link /dll $(LDEBUG) /out:gdal_GRIB.dll \
$(OBJ) degrib18\degrib\*.obj degrib18\g2clib-1.0.4\*.obj \
- $(GDAL_ROOT)/gdal_i.lib $(LINK_PNG) ..\zlib\*.obj
+ $(GDAL_ROOT)/gdal_i.lib $(LINK_PNG) $(ZLIB_LFLAGS)
Index: frmts/rik/makefile.vc
===================================================================
--- frmts/rik/makefile.vc (r�vision 28405)
+++ frmts/rik/makefile.vc (copie de travail)
@@ -5,7 +5,7 @@
!INCLUDE $(GDAL_ROOT)\nmake.opt
-EXTRAFLAGS = -I..\zlib
+EXTRAFLAGS = $(ZLIB_CFLAGS)
default: $(OBJ)
xcopy /D /Y *.obj ..\o
Index: frmts/georaster/makefile.vc
===================================================================
--- frmts/georaster/makefile.vc (r�vision 28405)
+++ frmts/georaster/makefile.vc (copie de travail)
@@ -18,7 +18,7 @@
!ENDIF
!ENDIF
-EXTRAFLAGS = $(OCI_INCLUDE) -I..\zlib $(JPEG_FLAGS)
+EXTRAFLAGS = $(OCI_INCLUDE) $(ZLIB_CFLAGS) $(JPEG_FLAGS)
default: $(OBJ)
xcopy /D /Y *.obj ..\o
@@ -37,7 +37,7 @@
plugin: $(PLUGIN_DLL)
$(PLUGIN_DLL): $(OBJ)
- link /dll $(LDEBUG) /out:$(PLUGIN_DLL) $(OBJ) $(GDALLIB) $(OCI_LIB) ..\zlib\*.obj \
+ link /dll $(LDEBUG) /out:$(PLUGIN_DLL) $(OBJ) $(GDALLIB) $(OCI_LIB) $(ZLIB_LFLAGS) \
..\jpeg\vsidataio.obj $(JPEG_LIB)
if exist $(PLUGIN_DLL).manifest mt -manifest $(PLUGIN_DLL).manifest -outputresource:$(PLUGIN_DLL);2
Index: frmts/mbtiles/makefile.vc
===================================================================
--- frmts/mbtiles/makefile.vc (r�vision 28405)
+++ frmts/mbtiles/makefile.vc (copie de travail)
@@ -1,7 +1,7 @@
OBJ = mbtilesdataset.obj
-EXTRAFLAGS = -I../../ogr -I../../ogr/ogrsf_frmts/geojson -I../../ogr/ogrsf_frmts/geojson/libjson -I../zlib
+EXTRAFLAGS = -I../../ogr -I../../ogr/ogrsf_frmts/geojson -I../../ogr/ogrsf_frmts/geojson/libjson $(ZLIB_CFLAGS)
GDAL_ROOT = ..\..
Index: port/makefile.vc
===================================================================
--- port/makefile.vc (r�vision 28405)
+++ port/makefile.vc (copie de travail)
@@ -57,7 +57,7 @@
!INCLUDE ..\nmake.opt
-EXTRAFLAGS = -I..\frmts\zlib -DHAVE_LIBZ
+EXTRAFLAGS = $(ZLIB_CFLAGS) -DHAVE_LIBZ
!IFDEF LIBICONV_INCLUDE
EXTRAFLAGS = $(EXTRAFLAGS) -DHAVE_ICONV $(LIBICONV_CFLAGS) $(LIBICONV_INCLUDE)
Index: ogr/makefile.vc
===================================================================
--- ogr/makefile.vc (r�vision 28405)
+++ ogr/makefile.vc (copie de travail)
@@ -1,12 +1,13 @@
LINKFLAGS = /Zi /MTd
-EXTRAFLAGS = -DWIN32 -I. -Iogrsf_frmts -Iogrsf_frmts\mem -I..\frmts\gtiff\libgeotiff -I..\frmts\zlib \
- $(PROJ_FLAGS) $(PROJ_INCLUDE) $(GEOS_CFLAGS)
+EXTRAFLAGS = -DWIN32 -I. -Iogrsf_frmts -Iogrsf_frmts\mem -I..\frmts\gtiff\libgeotiff $(PROJ_FLAGS) $(PROJ_INCLUDE) $(GEOS_CFLAGS)
GDAL_ROOT = ..
!INCLUDE ..\nmake.opt
+EXTRAFLAGS = $(EXTRAFLAGS) $(ZLIB_CFLAGS)
+
!IFDEF INCLUDE_OGR_FRMTS
EXTRAFLAGS = $(EXTRAFLAGS) -DOGR_ENABLED -DHAVE_MITAB
!ENDIF
More information about the gdal-dev
mailing list