3

I want to use osgeo tools in a virtualenv with Django. I already followed the directions in the Django manual succesfully on different linux systems. But this time I got stuck while intalling GDAL.

My system is Lubuntu 15.10.

$ tar xzf gdal-1.9.2.tar.gz
$ cd gdal-1.9.2
$ ./configure
$ make

After a while 'make' hangs with this message:

libtool: compile:  gcc -g -O2 -Wall -Wdeclaration-after-statement -DOGR_ENABLED -I/home/user/tmp/gdal-1.9.2/port -I/usr/include -c json_object.c  -fPIC -DPIC -o ../../o/.libs/json_object.o
In file included from /usr/include/string.h:634:0,
                 from /home/user/tmp/gdal-1.9.2/port/cpl_port.h:132,
                 from /home/user/tmp/gdal-1.9.2/port/cpl_conv.h:34,
                 from json_object.c:12:
json_object.c:29:9: error: expected identifier or '(' before '__extension__'
   char* strndup(const char* str, size_t n);
         ^
GNUmakefile:23: recipe for target '../../o/json_object.lo' failed

I could trace the problem back to this command

$ gcc -g -O2 -Wall -Wdeclaration-after-statement -DOGR_ENABLED -I/home/user/tmp/gdal-1.9.2/port -c /home/user/tmp/gdal-1.9.2/ogr/ogrsf_frmts/geojson/jsonc/json_object.c

which results in:

In file included from /usr/include/string.h:634:0,
              from /home/user/tmp/gdal-1.9.2/port/cpl_port.h:132,
              from /home/user/tmp/gdal-1.9.2/port/cpl_conv.h:34,
              from /home/user/tmp/gdal-1.9.2/ogr/ogrsf_frmts/geojson/jsonc/json_object.c:12:
/home/user/tmp/gdal-1.9.2/ogr/ogrsf_frmts/geojson/jsonc/json_object.c:29:9: error: expected identifier or ‘(’ before ‘__extension__’
char* strndup(const char* str, size_t n);

relevant lines in json_object.c are:

12 #include "cpl_conv.h"
13
14 #include "config.h"
15
16 #include <stdio.h>
17 #include <stdlib.h>
18 #include <stddef.h>
19 #include <string.h>
20
21 #include "debug.h"
22 #include "printbuf.h"
23 #include "linkhash.h"
24 #include "arraylist.h"
25 #include "json_object.h"
26 #include "json_object_private.h"
27
28 #if !HAVE_STRNDUP
29   char* strndup(const char* str, size_t n);
30 #endif /* !HAVE_STRNDUP */

I realize I am not working with the most recent version. It looks like Gdal-1.9.2 has a bug which caused my problem as commented by @huckfinn but finally I used the recent version Gdal-1.11.2 which does not cause any trouble. So problem is 'solved'

  • Should be present (..see linux.die.net/man/3/strndup) via /usr/include/string.h and linked against glibc. Do you work in such a GNU environment? What says ./configure to the strndup availabilty (yesy/no)? – huckfinn Feb 12 '16 at 19:38
  • I also see that you have a gdal-1.11.2 and a gdal-1.9.2 version in your post. Do you mixed somthing up? – huckfinn Feb 12 '16 at 19:43
  • don't know sure what you mean with 'what says ./configure ..'. The output of .configure in gdal-1.9.2 does not contain the text 'strndup'. If you want me to post the output of ./configure or anything else let me know. – waterbug Feb 12 '16 at 20:11
  • changed gdal-1.11.2 to gdal-1.9.2, was just a typo. (quite) sure i am not mixing up versions. – waterbug Feb 12 '16 at 20:12
  • I agree ~/install.d/gdal-2.0.1$ ./configure | grep strndup seems to be empty. In which operation system you try to build the library. This is important because, the function strndup() is a GNU extention not part of the C99 standard and not POSIX conform until version 200809L. ..see also stackoverflow.com/a/9168371/3338646 – huckfinn Feb 12 '16 at 20:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.