[Gdal-dev] Any possibility of static compile?

Frank Warmerdam warmerdam at pobox.com
Mon Dec 4 12:46:00 EST 2006


Curt Mills wrote:
> I need to do a static compile of my app.  I've been able to compile
> Shapelib, proj, geotiff, and a few other libraries statically so
> far.
> 
> I'd like to get GDAL compiled in, of which we use some of the OGR
> functions, but I recall reading earlier about some problems with
> static compiles of GDAL.  Is there a way to get OGR or the full
> GDAL/OGR library compiled statically these days?
> 
> There's also a way under Linux Standard Base rules to distribute a
> shared library along with the application, so that's my backup plan.
> I'd much rather distribute the entire thing statically linked if
> possible though.  Any hope?

Curt,

John pointed out some of the issues.  For what it is worth, I was able
to issue the following command against my local GDAL build:


  gcc -Ibld/include gdal/apps/gdalinfo.c gdal/libgdal.a -L/usr/local/lib -lgeos 
-lgeos_c -L/usr/local/lib -lxerces-c -lpthread -lNCSEcw -lNCSCnet -lNCSUtil 
-L/home/warmerda/pkg/HDF4.2r1/NewHDF/lib -lmfhdf -ldf -ljpeg -ltiff -lpng -lpq 
-L/usr/lib/postgresql/8.0/lib -lpq -lz -lpthread -lm -lrt -ldl 
-L/home/warmerda/pkg/kakadu-5.1/lib -lkdu -lsqlite3 -L/usr/lib -lcurl -lidn 
-lssl -lcrypto -ldl -lssl -lcrypto -ldl -lz -L/usr/lib -lmysqlclient -lz 
-lcrypt -lnsl -lm -o gdalinfo

This produced a gdalinfo executable with GDAL statically linked in, though
the various support libraries were still .so's.  I did this by configuring
GDAL "--without-libtool" and then linking against gdal/libgdal.a.  Essentially
I took the build's "gdal-config --libs" output replaced the part about -lgdal
itself with the path to libgdal.a, and used the rest unchanged.

So, one data point says static builds are doable.

Best regards,
-- 
---------------------------------------+--------------------------------------
I set the clouds in motion - turn up   | Frank Warmerdam, warmerdam at pobox.com
light and sound - activate the windows | http://pobox.com/~warmerdam
and watch the world go round - Rush    | President OSGeo, http://osgeo.org




More information about the Gdal-dev mailing list