error compiling libjson simple write example

Help
Alex
2013-07-11
2013-07-11
  • Alex
    Alex
    2013-07-11

    Hi,

    I intend to use libjson in my C++ application but I have problem compiling the libjson simple write example that comes with the download. I am suing the following command to compile.

    g++ -DNDEBUG test_libjson.cpp -I/usr/include/libjson -L/usr/local/lib/libjson.a

    the reason for -I and -L options is beacause that is where libjson and libjson.s have been installed after "make install".

    I receive the following error:

    /cygdrive/c/Users/E596482/AppData/Local/Temp/ccqhDtBp.o:test_libjson.cpp:(.text+0xc9): undefined reference to JSONNode::JSONN ode(std::string const&, char const*)' /cygdrive/c/Users/E596482/AppData/Local/Temp/ccqhDtBp.o:test_libjson.cpp:(.text+0x13b): undefined reference toJSONNode::JSON
    Node(std::string const&, int)'
    /cygdrive/c/Users/E596482/AppData/Local/Temp/ccqhDtBp.o:test_libjson.cpp:(.text+0x1af): undefined reference to JSONNode::JSON Node(std::string const&, double)' /cygdrive/c/Users/E596482/AppData/Local/Temp/ccqhDtBp.o:test_libjson.cpp:(.text+0x221): undefined reference toJSONNode::JSON
    Node(std::string const&, bool)'
    /usr/lib/gcc/i686-pc-cygwin/4.7.3/../../../../i686-pc-cygwin/bin/ld: /cygdrive/c/Users/E596482/AppData/Local/Temp/ccqhDtBp.o:
    bad reloc address 0xd in section `.text$_ZN30jsonSingletonEMPTY_JSON_STRINGD1Ev[__ZN30jsonSingletonEMPTY_JSON_STRINGD1Ev]'
    collect2: error: ld returned 1 exit status

    Please note that JSON_MEMORY_CALLBACKS is commented out in JSONOptions.h.

    Any help will be greatly appreciated. Thanks very much!