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
> 
> <[email protected]> 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
--- ogr/ogrsf_frmts/geojson/jsonc/json_object.c.ori	2017-04-28 19:32:06.465892181 +0200
+++ ogr/ogrsf_frmts/geojson/jsonc/json_object.c	2017-04-28 19:32:46.437595030 +0200
@@ -25,10 +25,6 @@
 #include "json_object.h"
 #include "json_object_private.h"
 
-#if !HAVE_STRNDUP
-  char* strndup(const char* str, size_t n);
-#endif /* !HAVE_STRNDUP */
-
 /* #define REFCOUNT_DEBUG 1 */
 
 const char *json_number_chars = "0123456789.+-eE";
--- ogr/ogrsf_frmts/geojson/jsonc/json_tokener.c.ori	2017-04-28 19:33:07.045446025 +0200
+++ ogr/ogrsf_frmts/geojson/jsonc/json_tokener.c	2017-04-28 19:33:23.645327974 +0200
@@ -118,28 +118,6 @@
 }
 
 
-#if !HAVE_STRNDUP
-/* CAW: compliant version of strndup() */
-char* strndup(const char* str, size_t n)
-{
-  if(str) {
-    size_t len = strlen(str);
-    size_t nn = json_min(len,n);
-    char* s = (char*)malloc(sizeof(char) * (nn + 1));
-
-    if(s) {
-      memcpy(s, str, nn);
-      s[nn] = '\0';
-    }
-
-    return s;
-  }
-
-  return NULL;
-}
-#endif
-
-
 #define state  tok->stack[tok->depth].state
 #define saved_state  tok->stack[tok->depth].saved_state
 #define current tok->stack[tok->depth].current
_______________________________________________
gdal-dev mailing list
[email protected]
https://lists.osgeo.org/mailman/listinfo/gdal-dev

Reply via email to