jsoncpp is auto detected when compilation does not work
Summary
jsoncpp is autodetected and enabled automatically. However, if gcc is not C++ enabled, it cannot find includes.
BIND version used
9.11.4-P2
Steps to reproduce
Tested on Fedora 29
- dnf -y install jsoncpp-devel
- cd bind-9.11*
- ./configure
- make -j4
What is the current bug behavior?
configure passes without problem. But compilation fails on strange error in json/config.h:
libtool: compile: gcc -I/home/pemensik/rhel/bind/bind-9.11.4-P2/build -I../../../.. -I../../../../lib/isc/unix/include -I../../../../lib/isc/unix/../pthreads/include -I../include -I../../../../lib/isc/unix/../include -I../../../../lib/isc/unix/.. -I/usr/include -D_REENTRANT -DOPENSSL -DDIG_SIGCHASE -D_GNU_SOURCE -O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -I/usr/include -DPK11_FLAVOR=PK11_SOFTHSMV2_FLAVOR -I/usr/include/libxml2 -fPIC -W -Wall -Wmissing-prototypes -Wcast-qual -Wwrite-strings -Wformat -Wpointer-arith -fno-strict-aliasing -fno-delete-null-pointer-checks -c ../../../../lib/isc/unix/entropy.c -fPIC -DPIC -o .libs/entropy.o
In file included from /usr/include/json/autolink.h:9,
from /usr/include/json/json.h:9,
from ../../../../lib/isc/unix/../include/isc/json.h:36,
from ../../../../lib/isc/unix/../include/isc/mem.h:19,
from ../../../../lib/isc/unix/pk11_api.c:21:
/usr/include/json/config.h:9:10: fatal error: string: No such file or directory
#include <string> //typedef String
^~~~~~~~
compilation terminated.
make[3]: *** [Makefile:172: pk11_api.lo] Error 1
make[3]: *** Waiting for unfinished jobs....
In file included from /usr/include/json/autolink.h:9,
from /usr/include/json/json.h:9,
from ../../../../lib/isc/unix/../include/isc/json.h:36,
from ../../../../lib/isc/unix/../include/isc/mem.h:19,
from ../../../../lib/isc/unix/app.c:32:
/usr/include/json/config.h:9:10: fatal error: string: No such file or directory
#include <string> //typedef String
^~~~~~~~
compilation terminated.
make[3]: *** [Makefile:172: app.lo] Error 1
In file included from /usr/include/json/autolink.h:9,
from /usr/include/json/json.h:9,
from ../../../../lib/isc/unix/../include/isc/json.h:36,
from ../../../../lib/isc/unix/../include/isc/mem.h:19,
from ../../../../lib/isc/unix/../entropy.c:32,
from ../../../../lib/isc/unix/entropy.c:64:
/usr/include/json/config.h:9:10: fatal error: string: No such file or directory
#include <string> //typedef String
^~~~~~~~
compilation terminated.
make[3]: *** [Makefile:172: entropy.lo] Error 1
What is the expected correct behavior?
Bind compiles fine
Relevant configuration files
$ rpm -q jsoncpp-devel gcc
jsoncpp-devel-1.8.4-5.fc29.x86_64
gcc-8.3.1-2.fc29.x86_64
Possible fixes
One fix would be make json-c preferred in configure.ac. If that is installed, do not use jsoncpp.
More correct fix might be something like:
AC_TRY_COMPILE([#include <json/json.h>], [], [have_libjson="yes"], [havelibjson="no"])
Because a bit naive detection by filename, it does not discover includes cannot be satisfied this way, compiler is not able to use it even when include is present.