Compiling a program with a depency on json-c

422 views
Skip to first unread message

Jeremy Klurr

unread,
Nov 26, 2015, 6:05:05 AM11/26/15
to jso...@googlegroups.com
I'm trying to compile this program
http://stackapps.com/questions/2802/stackoverflow-cli-a-nix-stackoverflow-command-line-client

Just running make resulted in "<json/json.h> not found" error.

Cloning repository from github and
> sh autogen.sh
> ./configure
> make
> sudo make install
'ing it didn't help it.

Eric Haszlakiewicz

unread,
Nov 26, 2015, 11:38:19 AM11/26/15
to jso...@googlegroups.com

json-c will install into /usr/local by default, so you either need to tell that stackoverflow-cli build to look there for it (through configure options, or perhaps CFLAGS) or build and install json-c with a "--prefix=/"

Eric

amigode...@gmail.com

unread,
Nov 27, 2015, 2:32:00 AM11/27/15
to json-c
On Thursday, November 26, 2015 at 8:38:19 PM UTC+4, Eric wrote:

json-c will install into /usr/local by default, so you either need to tell that stackoverflow-cli build to look there for it (through configure options, or perhaps CFLAGS) or build and install json-c with a "--prefix=/"

Eric


 Fixed this by changing #include <json/json.h> to #include <json-c/json.h>. I wonder when the renaming happened.

Now I'm getting this error instead:
cc -o stackoverflow-cli -ljson -lcurl stackoverflow.o requests.o arguments.o stackoverflow-cli.o
/usr/bin/ld: cannot find -ljson

Eric Haszlakiewicz

unread,
Nov 27, 2015, 11:53:53 AM11/27/15
to jso...@googlegroups.com

On Fri, Nov 27, 2015 at 2:32 AM, <amigode...@gmail.com> wrote:
>  Fixed this by changing #include <json/json.h> to #include <json-c/json.h>. I wonder when the renaming happened.
>
> Now I'm getting this error instead:
> cc -o stackoverflow-cli -ljson -lcurl stackoverflow.o requests.o arguments.o stackoverflow-cli.o
> /usr/bin/ld: cannot find -ljson
>

Oh, that's the same "problem", just on the link side.  We changed the name of the library from "json" to "json-c" to help avoid conflicts with other json libraries.  Unsurprisingly, many of them use "libjson.so", which can cause various hard to puzzle out errors.
You should just change whereever in the stackoverflow-cli makesfiles it says "-ljson" and use "-ljson-c".

Eric

Eric Haszlakiewicz

unread,
Nov 27, 2015, 8:37:22 PM11/27/15
to jso...@googlegroups.com
On Fri, Nov 27, 2015 at 2:32 AM, <amigode...@gmail.com> wrote:

>  Fixed this by changing #include <json/json.h> to #include <json-c/json.h>. I wonder when the renaming happened.


Fwiw, "when" was a while ago, starting on July 29, 2012 and available in the 0.11 release:
https://github.com/json-c/json-c/commit/c2d3ccf3af079d7b155b50e3974a5851af024383

However, there was a compat shim in place until much later.  It wasn't removed until Feb 11, 2014, which would have been in the 0.12 release:
https://github.com/json-c/json-c/commit/c8ee9196420c4b7c295a38c397a4e315df1baa03

Incidentally, given the age of the 0.12 release, we're probably due for a new one sometime soon, whenever I find some round tuits.

Eric
Reply all
Reply to author
Forward
0 new messages