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?

djechlin
  • 59,258
  • 35
  • 162
  • 290
Alon_T
  • 1,430
  • 4
  • 26
  • 47

2 Answers2

1

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

Icarus3
  • 2,310
  • 14
  • 22
  • 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" – Alon_T Dec 24 '12 at 17:43
  • 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. – Icarus3 Dec 24 '12 at 17:48
  • result is /usr/include/jsoncpp-src-0.5.0/include/json/json.h – Alon_T Dec 24 '12 at 17:48
  • then add -I/usr/include/jsoncpp-src-0.5.0/include – Icarus3 Dec 24 '12 at 17:49
  • Yeah I figured thats what you meant..Worked like charm...thanks! – Alon_T Dec 24 '12 at 17:50
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

Tristram Gräbener
  • 9,601
  • 3
  • 34
  • 50