all.
I'm having trouble using the JSON-C library on an OpenWRT linux distribution. I made a simple program below in order to test it.
#include <json/json.h>
int main() {
char * string = "{\"name\" : \"joys of programming\"}";
json_object * jobj = json_tokener_parse(string);
}
I then compile it with the following command.
gcc test.c -o test -ljson-c
However, I get the following errors.
In function `main':
test.c:(.text+0x2c): undefined reference to `json_tokener_parse'
test.c:(.text+0x38): undefined reference to `json_tokener_parse'
collect2: ld returned 1 exit status
I even compiled it with the command below, but it still didn't work.
gcc -ljson-c test.c -o test
I then tried to add the -L parameter when compiling, but still no luck.
gcc test.c -o test -L/usr/lib -ljson-c
This OpenWRT distribution uses opkg as its package installer, and here's what displays when I run opkg install libjson-c.
Package libjson-c (0.11-2) installed in root is up to date.
I even ran the compile command with the -E parameter to see if the correct header is being used, and it seems like it is as I can find the method declaration json_tokener_parse. I'm not really sure where I'm going wrong. I'm about to do a manual installation from Github, but I don't really want to do that because I would have to manually install other programs as well. Does anyone have any suggestions?
Thanks.