小编Jay*_* Le的帖子

问题包括jsonCpp标头

我正在尝试在我的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需要额外的东西吗?

感谢您的时间!

c++ compiler-errors header include jsoncpp

3
推荐指数
1
解决办法
2万
查看次数

标签 统计

c++ ×1

compiler-errors ×1

header ×1

include ×1

jsoncpp ×1