[gdal-dev] GDAL Java Bindings - Unable to use same jar on linux and windows

Even Rouault even.rouault at spatialys.com
Tue Jan 5 06:59:49 PST 2016


Le mardi 05 janvier 2016 15:33:49, johie a écrit :
> Hi everyone,
> 
> I have a problem with the GDAL 2.1.0 DEV version. I'm developing an
> application, which uses GDAL Java Bindings. I have been doing development
> with windows, and been using the gisinternals GDAL binaries
> (http://download.gisinternals.com/sdk/downloads/release-1800-x64-gdal-mapse
> rver.zip), from 18 december 2015.
> 
> The problem is that I need to run the application with Centos 7 (OpenJDK
> Java 8, SWIG 2.0.10), and there are no ready Java bindings (at least I have
> not found). I downloaded the latest trunk from git (around same time when
> installed the windows binaries, 20.12.2015), and build the gdal and swig
> bindings succesfully. The problem seems to be somewhat different filenaming
> inside the jar files.
> 
> If I run my application inside windows using the centos made .jar, I get:
> java.lang.UnsatisfiedLinkError:
> org.gdal.gdal.gdalJNI.Dataset_SWIGUpcast(J)J at
> org.gdal.gdal.gdalJNI.Dataset_SWIGUpcast(Native Method)
> 
> If I run it on centos, with windows made .jar I get,
> 
> Exception in thread "main" java.lang.UnsatisfiedLinkError:
> org.gdal.gdal.gdalJNI.SWIGDatasetUpcast(J)J
>         at org.gdal.gdal.gdalJNI.SWIGDatasetUpcast(Native Method).
> 
> The only difference I can notice between them, is the name of those
> methods/classes.
> 
> Any ideas how could I solve this problem? I would like to continue
> developing with windows and then just move the shaded jar to the centos. I
> did not have this problem when using the stable 2.0 version, however I need
> some functionalities of the development version :)

The issue comes from different SWIG version being used to generate the .java 
bindings file

GISInternals must used SWIG 1.3.40 (SWIGDatasetUpcast) whereas CentOS 7 with 
SWIG 2.0.10 generates Dataset_SWIGUpcast.
If you want to have GISInternals as a reference, then you could try to use 
swig 1.3.40 on your CentOS too:
- download swig 1.3.40
- ./configure --prefix=$HOME/install-swig-1.3.40
- make && make install
- and then when building the GDAL Java bindings make sure $HOME/install-
swig-1.3.40/bin is in the front of the $PATH. Or edit gdal/swig/SWIGmake.base 
so that the SWIG variable points to $HOME/install-swig-1.3.40/bin/swig


> 
> Thanks a lot,
> 
> Jesse
> 
> 
> 
> 
> 
> 
> 
> --
> View this message in context:
> http://osgeo-org.1560.x6.nabble.com/gdal-dev-GDAL-Java-Bindings-Unable-to-
> use-same-jar-on-linux-and-windows-tp5243795.html Sent from the GDAL - Dev
> mailing list archive at Nabble.com.
> _______________________________________________
> gdal-dev mailing list
> gdal-dev at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/gdal-dev

-- 
Spatialys - Geospatial professional services
http://www.spatialys.com


More information about the gdal-dev mailing list