我正在尝试在我的C++代码中实现jsoncpp库,我编写了一段简单的代码来试试它,它甚至都没有编译.
#include <stdio.h>
#include <stdlib.h>
#include <stddef.h>
#include <string.h>
#ifndef json_included
#define json_included
#include "jsoncpp\include\json\json.h"
#endif
//#include "json\jsonC\json.h"
int main(int argc, char **argv)
{
std::string example = "{\"array\":[\"item1\", \"item2\"], \"not an array\":\"asdf\"}";
Json::Value value;
Json::Reader reader;
bool parsed = reader.parse(example, value, false);
std::cout << parsed;
return 0;
}
Run Code Online (Sandbox Code Playgroud)
我得到的错误是:
undefined reference to `Json::Reader::parse(std::string const&, Json::Value&, bool)'
undefined reference to `Json::Reader::Reader()'
undefined reference to `Json::Value::~Value()'
undefined reference to `Json::Value::Value(Json::ValueType)'
Run Code Online (Sandbox Code Playgroud)
我对C++有点新意,在include语句中有什么我想念的吗?或者jsonCpp需要额外的东西吗?
感谢您的时间!