0
我想使用Jsoncpp創建Json消息。 我做了如下:使用JsonCpp創建Json消息
g++ -o clients clients.cpp -ljsoncpp -lzmq
這個誤差發生種類:
clients.cpp:(.text._ZN20multi_usrp_emulation7client1Ev[_ZN20multi_usrp_emulation7client1Ev ]+0x1d9): undefined reference to `Json::Value::operator=(Json::Value)'
clients.cpp:(.text._ZN20multi_usrp_emulation7client1Ev[_ZN20multi_usrp_emulation7client1Ev ]+0x224): undefined reference to `Json::Value::operator=(Json::Value)'
clients.cpp:(.text._ZN20multi_usrp_emulation7client1Ev[_ZN20multi_usrp_emulation7client1Ev ]+0x26c): undefined reference to `Json::Value::operator=(Json::Value)'
collect2: error: ld returned 1 exit status
什麼是錯我的代碼
#include <string>
#include <iostream>
#include <sstream>
#include <json/json.h>
int main()
{
std::string Value = "5.17e9";
std::string Type = "TX";
std::string Parameter = "Frequency";
Json::Value root;
root.append("Type");
root.append("Parameter");
root.append("Value");
root["Type"] = Type;
root["Parameter"] = Parameter;
root["Value"] = Value;
Json::FastWriter fastwriter;
std::string message = fastwriter.write(root);
std::cout<<message<<std::endl;
return 0;
}
使用下面的命令行編譯此代碼?
什麼版本jsoncpp您使用的是?也許它與這個問題有關:https://github.com/open-source-parsers/jsoncpp/issues/484? –
我不怎麼檢查版本。但我今天通過github下載了。我讀了你附帶的問題,但我不明白它的意思..你能幫助我嗎? –
版本是1.7.2的 –