1
我試過線程here和here的建議無濟於事。在OSX小牛上建立libjson
我安裝了Xcode 5.0.2,並且正在編譯命令行上的所有內容。化妝後/ make install來編譯libjson,我創建了一個簡單的測試文件,從它鏈接和構建:當我嘗試建立這個文件
#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;
}
:
g++ -DNDEBUG main.cpp -ljson
我得到這個:
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));
[創建一個libjson庫鏈接到xcode]可能的重複(http://stackoverflow.com/questions/20010975/creating-a-libjson-library-to-link-to-xcode) –