[gdal-dev] Building java bindings with GDAL 2.1.3

Even Rouault even.rouault at spatialys.com
Fri Apr 28 10:40:14 PDT 2017


On vendredi 28 avril 2017 10:13:41 CEST Paolo Corti wrote:
> Hi Even
> 
> On Fri, Apr 28, 2017 at 4:13 AM, Even Rouault
> 
> <even.rouault at spatialys.com> wrote:
> > Yes much likely this error is typical of a mismatch between SWIG 1.3 and
> > SWIG 2 or 3. It is likely that the gdal.jar in GeoServer was produced with
> > SWIG 1.3, so you'll need to generate the native part (libgdalconstjni.so,
> > etc...) with SWIG 1.3 as well (you can build it easily from source,
> > ./configure --prefix=$HOME/install-swig-1.3; make; make install and then
> > put $HOME/install-swig-1.3/bin in top of your PATH, before building again
> > the GDAL Java bindings). Or you may try to replace the gdal.jar located
> > somewhere in the geoserver installation with the one you've generated
> > with SWIG 3.
> > 
> > But in both cases I'm not completely sure that things will work due to a
> > few (subtle) changes in the GDAL Java API between GDAL 1.x used by this
> > old GeoServer and GDAL 2. Depends if GeoServer uses those API.
> 
> Thanks for the great help. Compiling with Swig 1.3 did not help (same
> error). I figured out, reading at this [1], that the the GeoServer GDAL
> plugin must use gdal 1.9.2, as must use imageio-ext-gdal-bindings-1.9.2.jar
> (I don't see that .jar available for other versions that 1.9.2).
> Therefore I believe the Swig error was caused by using gdal java
> bindings mixed between 1.9.2 and 2.1.3 versions.

Heck, latest GeoServer still using such an ancient version of GDAL... Or perhaps the doc is not 
up-to-date.

> 
> Therefore, I am trying to compile on Ubuntu 16.04 gdal 1.9.2, but I am
> now getting in this error [2].

I've managed with the attached patch (which removes the internal strndup() declaration and 
defintion). I've not tried if the build is running fine, but at least this compiles.

> Is there a workaround for this? The only alternative for me would be
> to install Ubuntu 14.04LTS in the server, where I know that gdal 1.9.2
> can be compiled correctly.

I guess you could probably upgrade to GDAL 1.11.X since the Java bindings must be 
compatible of GDAL 1.9.
In any case you still need to use SWIG 1.3

Even

-- 
Spatialys - Geospatial professional services
http://www.spatialys.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/gdal-dev/attachments/20170428/d894174f/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: json.patch
Type: text/x-patch
Size: 1150 bytes
Desc: not available
URL: <http://lists.osgeo.org/pipermail/gdal-dev/attachments/20170428/d894174f/attachment-0001.bin>


More information about the gdal-dev mailing list