I had too many problems with compiling different libraries for json and finally I got an already compiled library of json which is cJSON to be linked with my project but when I downloaded it, and linked it with a test c file like:
//file1.c
#include "cJSON.h"
...
...
...
then I compiled it through gcc using command:
gcc file1.c -lcJSON
it returns:
file1.c:7:19: fatal error: cJSON.h: No such file or directory
#include "cJSON.h"
Well, finally after several tries I succeed to figure out the problem and fix it. since cJSON is a static library so I can not perform dynamic linking like: -lcJSON
, the perfect way to compile file1.c and link cJSON lib to it, is by:
gcc cJSON.c file1.c -lm
.Finally compilation success.