[gdal-dev] undefined reference to `json_object_new_array linking with libgdal.a

Luí­s Moreira de Sousa luis.de.sousa at protonmail.ch
Wed Jul 22 01:46:56 PDT 2020


Hi Even, thank you for the reply.

libjson-c-dev is already installed in the system, and the linker can find it:

$ ld -ljson-c --verbose
[...]
==================================================
ld: mode elf_x86_64
attempt to open /usr/local/lib/x86_64-linux-gnu/libjson-c.so failed
attempt to open /usr/local/lib/x86_64-linux-gnu/libjson-c.a failed
attempt to open /lib/x86_64-linux-gnu/libjson-c.so failed
attempt to open /lib/x86_64-linux-gnu/libjson-c.a failed
attempt to open /usr/lib/x86_64-linux-gnu/libjson-c.so succeeded
/usr/lib/x86_64-linux-gnu/libjson-c.so
[...]

But the compiler still fails in the same way, whether I include the -json-c flag or not. Below is the output with the full compiler command:

g++ -I../../lib/dglib/include -I../../lib/shapelib/include -I../../lib/proj4lib/include -I/usr/include/gdal -O3 -std=c++11 -ljson-c -o dggrid binvals.o dggrid.o quadclip.o transform.o binpres.o gridgen.o DgHexSF.o param.o clipper.o table.o util.o ../../lib/dglib/lib/dglib.a ../../lib/shapelib/lib/shapelib.a ../../lib/proj4lib/lib/proj4lib.a /usr/lib/libgdal.a
/usr/bin/ld: /usr/lib/libgdal.a(shp_vsi.o): in function `SASetupDefaultHooks':
(.text+0x2d0): multiple definition of `SASetupDefaultHooks'; ../../lib/shapelib/lib/shapelib.a(safileio.o):safileio.c:(.text+0xc0): first defined here
/usr/bin/ld: /usr/lib/libgdal.a(ogrfeature.o): in function `OGRFeature::GetFieldAsSerializedJSon(int) const':
(.text+0x3861): undefined reference to `json_object_new_array'

Any other hints welcome. Thank you.

--
Luís

Sent with [ProtonMail](https://protonmail.com) Secure Email.

‐‐‐‐‐‐‐ Original Message ‐‐‐‐‐‐‐
On Tuesday, July 21, 2020 11:02 PM, Even Rouault <even.rouault at spatialys.com> wrote:

> Luí­s,
>
> normally GDAL builds out-of-the-box regarding libjson-c on Ubuntu.
>
> You have 2 possibilities, install libjson-c-dev, or let GDAL use its internal copy of libjson-c.
>
> In your linking attempts, this should be rather -ljson-c than -ljson, but normally you shouldn't have to do that.
>
> 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/20200722/8dfc6d46/attachment.html>


More information about the gdal-dev mailing list