Opened 10 years ago

Closed 10 years ago

#2783 closed defect (fixed)

Getting compile error when compiling json with custom json-dir

Reported by: robe Owned by: pramsey
Priority: blocker Milestone: PostGIS 2.2.0
Component: postgis Version: master
Keywords: Cc:

Description

I forget if this was after strk's change or pramsey's change.

Winnie is exhibiting this error:

configure part for json looks like

Using user-specified proj directory: /projects/proj/rel-4.8.0w32gcc48
checking proj_api.h usability... yes
checking proj_api.h presence... yes
checking for proj_api.h... yes
checking for pj_get_release in -lproj... yes
Using user-specified json-c directory: /projects/json-c/rel-0.10w32gcc48
checking json/json.h usability... yes
checking json/json.h presence... yes
checking for json/json.h... yes
checking for json_object_get in -ljson-c... no
checking for json_object_get in -ljson... yes
lwgeom_in_geojson.c:24:25: fatal error: json/json.h: No such file or directory
 #  include <json/json.h>
                         ^
compilation terminated.
<builtin>: recipe for target `lwgeom_in_geojson.o' failed

Change History (10)

comment:1 by robe, 10 years ago

Okay I think the include path is somehow getting lost. The line before the above error is:

gcc -O2 -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Wendif-labels -Wmissing-format-attribute -Wformat-security -fno-strict-aliasing -fwrapv -fexcess-precision=standard -g  -I../liblwgeom -I../libpgcommon  -I/projects/geos/rel-3.5.0devw32gcc481/include -I/projects/proj/rel-4.8.0w32gcc481/include -I/projects/libxml/rel-libxml2-2.7.8w32gcc481/include/libxml2  -I/projects/postgresql/rel/pg9.4w32gcc481/include  -I/projects/rel-libiconv-1.13.1w32gcc481/include -fPIC -I. -I./ -Ie:/jenkins/postgresql/rel/pg9.4w32gcc481/include/server -Ie:/jenkins/postgresql/rel/pg9.4w32gcc481/include/internal -I./src/include/port/win32 -DEXEC_BACKEND  "-Ie:/jenkins/postgresql/rel/pg9.4w32gcc481/lib/pgxs/src/makefiles/../../src/include/port/win32" -Ie:/jenkins/postgresql/rel/pg9.4w32gcc481/include/server/port/win32  -c -o lwgeom_in_geojson.o lwgeom_in_geojson.c
lwgeom_in_geojson.c:1:0: warning: -fPIC ignored for target (all code is position independent) [enabled by default]
 /**********************************************************************

note how there is absense of json-c include (maybe the JSON-CPP flags or something is wrong).

However if I look at the libtool lines, they do have the include and lib paths:

libtool: compile:  i686-w64-mingw32-gcc -g -O2 -DDLL_EXPORT -DPIC -Wall -Wmissing-prototypes -I/projects/geos/rel-3.5.0devw32gcc481/include -I/projects/proj/rel-4.8.0w32gcc481/include -I/projects/json-c/rel-0.10w32gcc481/include -ffloat-store -c lwspheroid.c -o lwspheroid.o >/dev/null 2>&1

/bin/sh ../libtool --tag=CC --mode=link i686-w64-mingw32-gcc -rpath /usr/local/lib stringbuffer.lo measures.lo measures3d.lo box2d.lo ptarray.lo lwgeom_api.lo lwgeom.lo lwpoint.lo lwline.lo lwpoly.lo lwtriangle.lo lwmpoint.lo lwmline.lo lwmpoly.lo lwcollection.lo lwcircstring.lo lwcompound.lo lwcurvepoly.lo lwmcurve.lo lwmsurface.lo lwpsurface.lo lwtin.lo lwout_wkb.lo lwin_geojson.lo lwin_wkb.lo lwout_wkt.lo lwout_twkb.lo lwin_wkt_parse.lo lwin_wkt_lex.lo lwin_wkt.lo lwutil.lo lwhomogenize.lo lwalgorithm.lo lwsegmentize.lo lwlinearreferencing.lo lwprint.lo vsprintf.lo g_box.lo g_serialized.lo g_util.lo lwgeodetic.lo lwgeodetic_tree.lo lwtree.lo lwout_gml.lo lwout_kml.lo lwout_geojson.lo lwout_svg.lo lwout_x3d.lo lwgeom_debug.lo lwgeom_geos.lo lwgeom_geos_clean.lo lwgeom_geos_node.lo lwgeom_geos_split.lo lwgeom_transform.lo lwspheroid.lo -release 2.2.0dev -L/projects/postgresql/rel/pg9.4w32gcc481/lib -L/projects/gdal/rel-1.11.0w32gcc481/lib -L/projects/rel-libiconv-1.13.1w32gcc481/lib -L/projects/geos/rel-3.5.0devw32gcc481/lib -lgeos_c -L/projects/proj/rel-4.8.0w32gcc481/lib -lproj -L/projects/json-c/rel-0.10w32gcc481/lib -ljson -o liblwgeom.la

comment:2 by robe, 10 years ago

Okay i compared the configure.ac scripts, and that is not what changed between 2.1 and 2.2. Only difference between them is the a line got commented out.

In 2.1 it's

AC_MSG_RESULT([CPPFLAGS: $CPPFLAGS])

In 2.2 it's

dnl AC_MSG_RESULT([CPPFLAGS: $CPPFLAGS])

Not sure why someone did that as I would think seeing that variable would be useful

I did find the smoking gun — it's exactly where the error says.

These lines were added in 2.2:

#ifdef HAVE_LIBJSON
# ifdef HAVE_LIBJSON_C
#  include <json-c/json.h>
# else
#  include <json/json.h>
# endif
#endif

If I remove them my code compiles again. I'm still puzzled why my json 0.9 works with these lines and my 0.10 doesn't. Unless if its something to do with the fact that it is static vs. 0.10 being dynamic.

why did we add these line here? they don't seem to be needed as far as I can tell.

comment:3 by robe, 10 years ago

As strk noted we need that include to get the version number. I was able to get things to compile by changing:

line 901 of configure.ac from

CPPFLAGS="$PGSQL_CPPFLAGS $GEOS_CPPFLAGS $PROJ_CPPFLAGS $XML2_CPPFLAGS $SFCGAL_CPPFLAGS $CPPFLAGS"

to

CPPFLAGS="$PGSQL_CPPFLAGS $GEOS_CPPFLAGS $PROJ_CPPFLAGS $XML2_CPPFLAGS $SFCGAL_CPPFLAGS $JSON_CPPFLAGS $CPPFLAGS"

still regress checking and if all are in agreement I'll go ahead and commit for 2.0-2.2

comment:4 by pramsey, 10 years ago

Commit it, looks good.

comment:5 by robe, 10 years ago

Summary: Getting compile error when compiling against json 0.10 in mingw64Getting compile error when compiling json with custom json-dir

committed to trunk (2.2) at r12688 also changed title of this since I don't think its a mingw64 issue and more has to do with custom json-dir.

I'm also thinking of not committing this to 2.1 or 2.0. Those ones don't have the version check so techinically they don't need this patch.

comment:6 by robe, 10 years ago

Resolution: fixed
Status: newclosed

Decided not to commit to 2.1 and 2.0 don't fix what isn't broken.

comment:7 by robe, 10 years ago

Resolution: fixed
Status: closedreopened

comment:8 by robe, 10 years ago

Oh boy fix one thing break another, now winnie's json 0.9 (PostgreSQL 9.1) is no longer happy. I was planning to upgrade it anyway but it's kinda annoying it works for one and not the other.

lwgeom_in_geojson.c:1:0: warning: -fPIC ignored for target (all code is position independent)

In file included from e:/jenkins/json-c/rel-0.9w64/include/json/json_util.h:15:0,
                 from e:/jenkins/json-c/rel-0.9w64/include/json/json.h:23,
                 from lwgeom_in_geojson.c:24:
e:/jenkins/json-c/rel-0.9w64/include/json/json_object.h:32:13: error: conflicting types for 'boolean'
c:\ming64\mingw64\bin\../lib/gcc/x86_64-w64-mingw32/4.5.4/../../../../x86_64-w64-mingw32/include/rpcndr.h:52:25: note: previous declaration of 'boolean' was here
make[1]: *** [lwgeom_in_geojson.o] Error 1
make[1]: Leaving directory `/projects/postgis/branches/2.2/postgis'
make: *** [all] Error 1

I think I got this error earlier on with 0.9 and just started compiling with -w option or something. Have to look at my notes.

comment:9 by robe, 10 years ago

oh yippie deja vu and I learned down my excursion of history lane that strk originally took out the json from configure.ac and moved it to lwgeom

http://trac.osgeo.org/postgis/ticket/2218

r11119

since this is likely only a windows version, I'm tempted to just upgrade the ones I have that use json 0.9 to newer (which I was goong to do anyway). As long as we don't port back these changes to 2.1 nd 2.0 which we shouldn't need to do since we are not reading version numbers in those. And if we do I guess I can just upgrade to newer json chain on those.

comment:10 by robe, 10 years ago

Resolution: fixed
Status: reopenedclosed

I'm not going to bother with 0.9 anymore for 2.2. Just upgraded 2.2 to use static compiled json 0.12. Since this 0.9 issue is probably a mingw only issue, probably not worth fixing when newer json works fine.

Note: See TracTickets for help on using tickets.