1

I've tried the advice on threads here and here to no avail.

I have Xcode 5.0.2 installed and I am compiling everything on the command line. After make/make install to build libjson, I created a simple test file to link and build from it:

#include <iostream>
#include "libjson.h"

int main(int argc, const char * argv[])
{

    // insert code here...
    std::cout << "Hello, World!\n";
    JSONNode n(JSON_NODE);
    n.push_back(JSONNode("RootA", "Hello World"));
    JSONNode c(JSON_ARRAY);
    c.set_name("ArrayOfNumbers");
    c.push_back(JSONNode("", 16));
    c.push_back(JSONNode("", 42));
    c.push_back(JSONNode("", 128));
    n.push_back(c);
    std::string jc = n.write_formatted();
    std::cout << jc << std::endl;
    return 0;
}

When I try to build this file:

g++ -DNDEBUG main.cpp -ljson

I get this:

main.cpp:17:5: error: unknown type name 'JSONNode'
    JSONNode n(JSON_NODE);
    ^
main.cpp:18:17: error: use of undeclared identifier 'JSONNode'
    n.push_back(JSONNode("RootA", "Hello World"));
                ^
main.cpp:19:5: error: unknown type name 'JSONNode'
    JSONNode c(JSON_ARRAY);
    ^
main.cpp:21:17: error: use of undeclared identifier 'JSONNode'
    c.push_back(JSONNode("", 16));
                ^
main.cpp:22:17: error: use of undeclared identifier 'JSONNode'
    c.push_back(JSONNode("", 42));
                ^
main.cpp:23:17: error: use of undeclared identifier 'JSONNode'
    c.push_back(JSONNode("", 128));
1

1 Answer 1

0

Found the answer from another SO question after I realized the make process had problems. Basically, the solution is to copy the source code into Xcode and build it as part of the project instead of trying to link it as a library.

I also tried to build libjson 7.6.1 on an ubuntu machine (12.04) and encountered the exact problem despite a perfect make.

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.