2

I'm trying to include and compile

#include <json/json.h>

However even though I've installed it and included it on the project settings it wouldn't find the path.

here's what I've so far done:

path to libjson:

 /usr/include/jsoncpp-src-0.5.0

options in eclipse gcc c++ compiler:

-Ijson_linux-gcc-4.5.2_libmt -O0 -g3 -Wall -c -fmessage-length=0 -ljson_linux-gcc-4.5.2_libmt

libraries in gcc c++ linker:

-L/usr/include/jsoncpp-src-0.5.0/include/

Anything else I forgot to do to make it work?

2
  • 1
    It would help if you put up an error message Commented Dec 24, 2012 at 17:39
  • It says in an error style next to the include line that theres no such file or directory so I guess it's my path that is wrong ... I dont quite know hot to add it Commented Dec 24, 2012 at 17:40

2 Answers 2

1

try adding -I/usr/include/jsoncpp-src-0.5.0 to compiler options

Sign up to request clarification or add additional context in comments.

5 Comments

I did..the outputs the same..the compile command is g++ -Ijson_linux-gcc-4.5.2_libmt -I/usr/include/jsoncpp-src-0.5.0 -O0 -g3 -Wall -c -fmessage-length=0 -Ijson_linux-gcc-4.5.2_libmt -MMD -MP -MF"src/libparser.d" -MT"src/libparser.d" -o"src/libparser.o"
You might want to search json.h on your file system. First check if it exists. I would use " find /usr/include -name "json.h" " to locate it. If it is at for example /usr/include/some/path/json/json.h then you will need to add -I/usr/include/some/path in compiler option.
result is /usr/include/jsoncpp-src-0.5.0/include/json/json.h
then add -I/usr/include/jsoncpp-src-0.5.0/include
Yeah I figured thats what you meant..Worked like charm...thanks!
1

-L indicates where to find shared libraries (e.g. .so)

-I is the search path for the header files.

If the problem occurs during compilation (json.h not found), then you have indicated the wrong -I

If it occurs during linking (symbol not found), then you have indicated a wrong -L, a wrong -l, or forgot to run ldconfig

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.