简体   繁体   English

有没有办法将 JSONcpp 库与 C++ 代码链接?

[英]Is there a way to link JSONcpp library with C++ code?

I used the python amalmagate file to compile the json library.我使用 python amalmagate 文件来编译 json 库。 Now when I run the c++ code, I keep getting this error.现在,当我运行 c++ 代码时,我不断收到此错误。

/usr/bin/ld: msort.cc:(.text+0x255): undefined reference to Json::Value::~Value()' /usr/bin/ld: msort.cc:(.text+0x264): undefined reference to Json::Value::~Value()' /usr/bin/ld: msort.cc:(.text+0x278): undefined reference to Json::Value::operator[](int)' /usr/bin/ld: msort.cc:(.text+0x28c): undefined reference to Json::Value::Value(char const*)' /usr/bin/ld: msort.cc:(.text+0x2a7): undefined reference to `Json::Value::get(char const*, Json::Value const&) const' /usr/bin/ld: msort.cc:(.text+0x255): 未定义对Json::Value::~Value()' /usr/bin/ld: msort.cc:(.text+0x264): undefined reference to Json::Value::~Value()' /usr/bin/ld: msort.cc:(.text+0x278) 的引用:未定义对Json::Value::operator[](int)' /usr/bin/ld: msort.cc:(.text+0x28c): undefined reference to引用Json::Value::operator[](int)' /usr/bin/ld: msort.cc:(.text+0x28c): undefined reference to Json::Value::Value(char const*)' /usr/bin/ld: msort.cc:(.text+0x2a7):未定义对 `Json::Value::get(char const*, Json::Value const&) const' 的引用

This is what I used to download the jsoncpp library这是我用来下载jsoncpp库的

git clone https://github.com/open-source-parsers/jsoncpp.git git 克隆https://github.com/open-source-parsers/jsoncpp.git

cd jsoncpp cd jsoncpp

python amalgamate.py python amalgamate.py

The code I ran to compile: g++ msort.cc -o msort我运行编译的代码:g++ msort.cc -o msort

I understand that this means that the library is not connecting with my code.我了解这意味着该库未与我的代码连接。 Any idea how I can fix this?知道如何解决这个问题吗?

If you read the instructions for the amalgamated library you will see that you need to build with the library source file dist/jsoncpp.cpp :如果您阅读了合并库的说明,您将看到您需要使用库源文件dist/jsoncpp.cpp进行构建:

g++ msort.cc dist/jsoncpp.cpp -o msort

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM