[gdal-dev] static linkage of GDAL and GDAL JNI

Nidel, Mike mike.nidel at lmco.com
Tue Aug 12 15:44:59 EDT 2008

I'm using GDAL from Java.

I wondered if anyone has statically linked libgdal into the gdaljni.so
for the purposes of Java/JNI interface usage. For anyone who has done
this from Java, you know that setting the java system property
java.library.path is sufficient for the JVM to find a DLL or shared lib
that is located in this path. The problem is that if THAT library
depends on another library in the way that gdaljni.dll/so depends on
gdal.dll/so, then the secondary library can't be located unless it is in

So for example, if you place the gdaljni.dll and gdal.dll in C:/gdal/lib
and set -Djava.library.path=C:/gdal/lib, then you get an error when
gdaljni.dll tries to load gdal.dll. If you also set PATH=C:\gdal\lib,
then it works fine.

I'd really rather not have to worry about the PATH (or LD_LIBRARY_PATH
on linux/unix), so building it all into a single DLL/SO is an
alternative. Does anyone have any thoughts on how to do this within the
GDAL build?



More information about the gdal-dev mailing list