Opened 4 years ago

Closed 4 years ago

Last modified 4 years ago

#6440 closed defect (fixed)

gdalinfo fails to build with external json-c

Reported by: Bas Couwenberg Owned by: warmerdam
Priority: normal Milestone: 2.0.3
Component: default Version: 2.0.2
Severity: normal Keywords:
Cc:

Description (last modified by Bas Couwenberg)

Triggered by #6438 I switched the GDAL Debian package build to use the external libjson-c with ./configure --with-libjson-c=/usr and this caused a build failure:

/bin/bash /build/gdal-2.0.2+dfsg/libtool --mode=compile --tag=CC gcc -I/build/gdal-2.0.2+dfsg/port -I/build/gdal-2.0.2+dfsg/gcore -I/build/gdal-2.0.2+dfsg/alg -I/build/gdal-2.0.2+dfsg/ogr -I/build/gdal-2.0.2+dfsg/ogr/ogrsf_frmts -g -O2 -fstack-protector-strong -Wformat -fvisibility=hidden  -Wall -Wdeclaration-after-statement  -I/build/gdal-2.0.2+dfsg/frmts/vrt -DOGR_ENABLED -Wdate-time -D_FORTIFY_SOURCE=2 -I/build/gdal-2.0.2+dfsg/port -I/usr/include -I/usr/include  -DGDAL_COMPILATION -I/usr/include/json-c -I/build/gdal-2.0.2+dfsg/ogr/ogrsf_frmts/geojson -DHAVE_GEOS=1 -I/usr/include -c -o gdalinfo.lo gdalinfo.c
libtool: compile:  gcc -I/build/gdal-2.0.2+dfsg/port -I/build/gdal-2.0.2+dfsg/gcore -I/build/gdal-2.0.2+dfsg/alg -I/build/gdal-2.0.2+dfsg/ogr -I/build/gdal-2.0.2+dfsg/ogr/ogrsf_frmts -g -O2 -fstack-protector-strong -Wformat -fvisibility=hidden -Wall -Wdeclaration-after-statement -I/build/gdal-2.0.2+dfsg/frmts/vrt -DOGR_ENABLED -Wdate-time -D_FORTIFY_SOURCE=2 -I/build/gdal-2.0.2+dfsg/port -I/usr/include -I/usr/include -DGDAL_COMPILATION -I/usr/include/json-c -I/build/gdal-2.0.2+dfsg/ogr/ogrsf_frmts/geojson -DHAVE_GEOS=1 -I/usr/include -c gdalinfo.c  -fPIC -DPIC -o .libs/gdalinfo.o
libtool: compile:  gcc -I/build/gdal-2.0.2+dfsg/port -I/build/gdal-2.0.2+dfsg/gcore -I/build/gdal-2.0.2+dfsg/alg -I/build/gdal-2.0.2+dfsg/ogr -I/build/gdal-2.0.2+dfsg/ogr/ogrsf_frmts -g -O2 -fstack-protector-strong -Wformat -fvisibility=hidden -Wall -Wdeclaration-after-statement -I/build/gdal-2.0.2+dfsg/frmts/vrt -DOGR_ENABLED -Wdate-time -D_FORTIFY_SOURCE=2 -I/build/gdal-2.0.2+dfsg/port -I/usr/include -I/usr/include -DGDAL_COMPILATION -I/usr/include/json-c -I/build/gdal-2.0.2+dfsg/ogr/ogrsf_frmts/geojson -DHAVE_GEOS=1 -I/usr/include -c gdalinfo.c -o gdalinfo.o >/dev/null 2>&1
/bin/bash /build/gdal-2.0.2+dfsg/libtool --mode=compile --tag=CXX g++ -I/build/gdal-2.0.2+dfsg/port -I/build/gdal-2.0.2+dfsg/gcore -I/build/gdal-2.0.2+dfsg/alg -I/build/gdal-2.0.2+dfsg/ogr -I/build/gdal-2.0.2+dfsg/ogr/ogrsf_frmts -g -O2 -fstack-protector-strong -Wformat -fvisibility=hidden  -Wall  -I/build/gdal-2.0.2+dfsg/frmts/vrt -DOGR_ENABLED -Wdate-time -D_FORTIFY_SOURCE=2 -I/build/gdal-2.0.2+dfsg/port -I/usr/include -I/usr/include  -DGDAL_COMPILATION -I/usr/include/json-c -I/build/gdal-2.0.2+dfsg/ogr/ogrsf_frmts/geojson -DHAVE_GEOS=1 -I/usr/include -c -o commonutils.lo commonutils.cpp
libtool: compile:  g++ -I/build/gdal-2.0.2+dfsg/port -I/build/gdal-2.0.2+dfsg/gcore -I/build/gdal-2.0.2+dfsg/alg -I/build/gdal-2.0.2+dfsg/ogr -I/build/gdal-2.0.2+dfsg/ogr/ogrsf_frmts -g -O2 -fstack-protector-strong -Wformat -fvisibility=hidden -Wall -I/build/gdal-2.0.2+dfsg/frmts/vrt -DOGR_ENABLED -Wdate-time -D_FORTIFY_SOURCE=2 -I/build/gdal-2.0.2+dfsg/port -I/usr/include -I/usr/include -DGDAL_COMPILATION -I/usr/include/json-c -I/build/gdal-2.0.2+dfsg/ogr/ogrsf_frmts/geojson -DHAVE_GEOS=1 -I/usr/include -c commonutils.cpp  -fPIC -DPIC -o .libs/commonutils.o
libtool: compile:  g++ -I/build/gdal-2.0.2+dfsg/port -I/build/gdal-2.0.2+dfsg/gcore -I/build/gdal-2.0.2+dfsg/alg -I/build/gdal-2.0.2+dfsg/ogr -I/build/gdal-2.0.2+dfsg/ogr/ogrsf_frmts -g -O2 -fstack-protector-strong -Wformat -fvisibility=hidden -Wall -I/build/gdal-2.0.2+dfsg/frmts/vrt -DOGR_ENABLED -Wdate-time -D_FORTIFY_SOURCE=2 -I/build/gdal-2.0.2+dfsg/port -I/usr/include -I/usr/include -DGDAL_COMPILATION -I/usr/include/json-c -I/build/gdal-2.0.2+dfsg/ogr/ogrsf_frmts/geojson -DHAVE_GEOS=1 -I/usr/include -c commonutils.cpp -o commonutils.o >/dev/null 2>&1
/bin/bash /build/gdal-2.0.2+dfsg/libtool --mode=link    g++ -Wl,-z,relro -Wl,-z,now gdalinfo.lo commonutils.lo  /build/gdal-2.0.2+dfsg/libgdal.la -o gdalinfo
libtool: link: g++ -Wl,-z -Wl,relro -Wl,-z -Wl,now .libs/gdalinfo.o .libs/commonutils.o -o .libs/gdalinfo  /build/gdal-2.0.2+dfsg/.libs/libgdal.so -pthread 
/usr/bin/ld: .libs/gdalinfo.o: undefined reference to symbol 'json_object_new_int'
//lib/x86_64-linux-gnu/libjson-c.so.2: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status

The attached patch adds -ljson-c to the link flags when external libjson-c is used.

Attachments (1)

libjson-c.patch (743 bytes) - added by Bas Couwenberg 4 years ago.

Download all attachments as: .zip

Change History (4)

Changed 4 years ago by Bas Couwenberg

Attachment: libjson-c.patch added

comment:1 Changed 4 years ago by Bas Couwenberg

Description: modified (diff)

comment:2 Changed 4 years ago by Even Rouault

Resolution: fixed
Status: newclosed

I tried to reproduce locally on my Ubuntu 14.04.4 LTS, but didn't get any link error. Perhaps due to different libtool versions

See

$ make gdalinfo
/bin/bash /home/even/gdal/2.0/gdal/libtool --mode=link	g++  gdalinfo.lo commonutils.lo  /home/even/gdal/2.0/gdal/libgdal.la -o gdalinfo
libtool: link: g++ .libs/gdalinfo.o .libs/commonutils.o -o .libs/gdalinfo  /home/even/gdal/2.0/gdal/.libs/libgdal.so -L/usr/lib -L/home/even/instantclient_12_1/lib -L/home/even/gdal/install-libkml-master/lib -L/home/even/gdal/FileGDB_API/lib -larmadillo -lpoppler -ljson-c -lfreexl -lgeos_c -lclntsh -lnnz12 -lodbc -lodbcinst /home/even/gdal/libkml-master/../install-libkml-master/lib/libkmldom.so /home/even/gdal/libkml-master/../install-libkml-master/lib/libkmlengine.so /home/even/gdal/libkml-master/../install-libkml-master/lib/libkmlbase.so /home/even/gdal/libkml-master/../install-libkml-master/lib/libkmlconvenience.so /home/even/gdal/libkml-master/../install-libkml-master/lib/libminizip.so /home/even/gdal/libkml-master/../install-libkml-master/lib/liburiparser.so /usr/lib/x86_64-linux-gnu/libexpat.so -lxerces-c -ljasper -lnetcdf -lhdf5 /usr/lib/libmfhdfalt.so /usr/lib/libdfalt.so -logdi -lgif -ljpeg -lgeotiff /usr/lib/x86_64-linux-gnu/libtiff.so -lpng -lcfitsio -lpq -lrt -lspatialite /usr/lib/x86_64-linux-gnu/libsqlite3.so -lpcre /usr/lib/x86_64-linux-gnu/libcurl-gnutls.so -lFileGDBAPI -lfgdbunixrtl -lxml2 -lmysqlclient -lpthread -lz -ldl -pthread  -Wl,-rpath -Wl,/home/even/gdal/libkml-master/../install-libkml-master/lib

Anyway, I applied branches/2.0 r33882 "When using external libjson, explictly link GDAL utilities (particularly gdalinfo that directly uses libjson) against it (derived from patch by Sebastian Couwenberg, #6440)" . The complement w.r.t your proposed patch is to be able to handle external libjson in non system location.

I don't think this is needed in trunk since code from gdalinfo has been migrated into libgdal itself.

comment:3 Changed 4 years ago by Bas Couwenberg

Thanks, I've replaced my patch with the changes from r33882 in the Debian package. It's included in gdal (2.0.2+dfsg-5) uploaded to Debian unstable today.

I can confirm that 2.1.0beta1 doesn't need the changes, it builds successfully with external json-c without further changes.

Note: See TracTickets for help on using tickets.