Opened 11 years ago

Closed 10 years ago

#2539 closed enhancement (fixed)

Check for json-c/json.h presence/usability before json/json.h

Reported by: Mike Taves Owned by: pramsey
Priority: medium Milestone: PostGIS 2.1.4
Component: postgis Version: 2.1.x
Keywords: Cc:


Newer versions of the json-c library have changed their configuration:

#include <json/json.h>

has changed to:

#include <json-c/json.h>

and the compile flag -ljson has changed to -ljson-c.

This order of preference to the newer style should be reflected in the ./configure process.

See related #2538.

Change History (11)

comment:1 by brunofriedmann, 10 years ago

Should be also backported to 2.1 x branch

comment:2 by pramsey, 10 years ago

Resolution: fixed
Status: newclosed

2.1 branch at r12347

comment:3 by kzalewski, 10 years ago

Resolution: fixed
Status: closedreopened

Although detection of json-c/json.h is now working during the configure stage, compilation of PostGIS 2.1.2 still fails when using json-c 0.12.

The file liblwgeom/lwin_geojson.c contains the following headers:

#include <json/json.h>
#include <json/json_object_private.h>

which yields this compilation error:

libtool: compile:  gcc -O2 -fPIC -fPIC -DPIC -Wall -Wmissing-prototypes -I/usr/include -c lwin_geojson.c  -fPIC -DPIC -o .libs/lwin_geojson.o
lwin_geojson.c:20:23: fatal error: json/json.h: No such file or directory
compilation terminated.

In addition, once the #include lines are changed to <json-c/json.h> and <json-c/json_object_private.h>, there is an additional compilation error:

libtool: compile:  gcc -O2 -fPIC -fPIC -DPIC -Wall -Wmissing-prototypes -I/usr/include -c lwin_geojson.c  -fPIC -DPIC -o .libs/lwin_geojson.o
lwin_geojson.c: In function 'parse_geojson_coord':
lwin_geojson.c:71:6: warning: unused variable 'iType' [-Wunused-variable]
lwin_geojson.c: In function 'lwgeom_from_geojson':
lwin_geojson.c:515:43: error: 'json_tokener_errors' undeclared (first use in this function)
lwin_geojson.c:515:43: note: each undeclared identifier is reported only once for each function it appears in

The json_tokener_errors[] array has been replaced in json-c 0.12 with a function json_tokener_error_desc(). So a simple edit needs to be made to change:




Making this simple change from the deprecated array to the new function allows compilation to proceed to completion.

comment:4 by kzalewski, 10 years ago

I am also confirming that the two problems that I listed in this ticket (both are in lwin_geojson.c) are present in PostGIS 2.1.3 as well.

comment:5 by robe, 10 years ago

Milestone: PostGIS 2.1.2PostGIS 2.1.4

comment:6 by strk, 10 years ago

json_tokener_error_desc() is available in libjson-0.11 too. What's the minimum version of libjson we support ?

comment:7 by strk, 10 years ago

We support 0.9 or higher, from the README in postgis-2.1

comment:8 by strk, 10 years ago

0.9 did not have json_tokener_error_desc, I guess we could switch on the presence of JSON_C_VERSION

comment:9 by strk, 10 years ago

I see json_tokener_error_desc already used in trunk version of liblwgeom/lwin_geojson.c, does that mean we require 0.10 for 2.2.0 ? Does trunk work for you kzalewski and robe ?

comment:10 by strk, 10 years ago

libjson-c 0.10 also has json_tokener_error_desc() — As we use it already in trunk I documented trunk as requiring 0.10 or higher with r12653 — as this ticket is for 2.1 branch I'll keep it open until anyone decides it's not worth fixing there or implements a conditional build.

comment:11 by strk, 10 years ago

Resolution: fixed
Status: reopenedclosed

Actually I found that the 0.12 support for 2.1 branch is already discussed in #2723, so closing this one out.

Note: See TracTickets for help on using tickets.