[gdal-dev] Unable to get multi-platform JAR working for GDAL 2.x

Lander, Steven steven.lander at rgi-corp.com
Tue May 3 09:54:08 PDT 2016


I have been struggling to get a working gdal.jar for both Windows and Linux for a few days/weeks now.  A previous issue reported to the mailing list outlines the issue: http://lists.osgeo.org/pipermail/gdal-dev/2016-January/043357.html

For windows, I am using Windows 10 64 bit, along with the 64-bit GDAL dev release which reports to be 2.1.0beta1 when I run gdalinfo --version.  This is also confirmed by the information page for the release: http://www.gisinternals.com/packageinfo.php?file=release-1800-x64-gdal-mapserver.zip.  They also state that it was compiled with SWIG 2.0.4 but I have no way to independently verify that.

On Linux, I get the stable release of 2.1.0 and compile it just fine, using SWIG 2.0.4 as stated in the earlier thread.  I make the GDAL java bindings with no issue.

The problem seems to be Windows will NOT use the jar compiled on Linux and vice versa.  Whenever I try to use the Jar from one platform on another platform, I get an UnsatisfiedLink exception pointing to either Dataset_SWIGUpcast or SWIGDatasetUpcast being the problem.

On each platform I have the location of the GDAL JNI files in the PATH (Windows) or LD_LIBRARY_PATH (Linux).  I use Gradle to build and run my software on each platform, and the GDAL jar is being imported in the gradle file from a lib folder.  As mentioned in the thread Even Roualt responded to, I have tried numerous times on Linux to build the bindings for SWIG using version 1.3.40, 2.0.4, and even 3.0.x.  Nothing I do can get this Upcast issue to go away.

* Is this just not possible?  Do I absolutely have to use the same jar compiled for my platform?
* All GISInternals releases seem to use SWIGDatasetUpcast to register GDAL drivers
* Linux builds make Dataset_SWIGUpcast no matter what SWIG version I compile with.  I have verified this by compiling the java swig project, unzipping the Jars, and running the GNU strings command on the gdalJNI.class file to see the method names in that file.
* Are the CPP files for gdalJNI not the same for each platform?  How is it I am getting two different scenarios where Windows will only work if SWIGDatasetUpcast is present and Linux will only work if Dataset_SWIGUpcast is present in gdalJNI.class?
* Ultimately I just want to be able to use 1 gdal.jar in my project so that IntelliJ does not have to worry about which version to load.  IntelliJ names the Jar explicitly in it's module folder structure and those files are supposed to be in source.  If that file is different for Windows and Linux users, then that creates version headaches for my devs.
* I can easily make this issue moot by having gradle detect my platform and load the appropriate jar by unique name at test/compile time, but that will not work for my IntelliJ/source control issue

Any ideas?  I am struggling to think of other ways to troubleshoot this issue..

Steven D. Lander, Software Engineer
Reinventing Geospatial, Inc

Steven.Lander AT rgi-corp DOT com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/gdal-dev/attachments/20160503/1fe72b07/attachment-0001.html>


More information about the gdal-dev mailing list