我是json的新手,我试图从本教程网站读取我的json文件 https://en.wikibooks.org/wiki/JsonCpp
然而我收到一些链接器错误
1> ------ Build build:Project:TwilightAdventure,配置:Debug Win32 ------ 1 GT;创建库C:\ Users \ MinTeckNG \ Desktop \ TwilightAdventure \ Debug \ TwilightAdventure.lib和对象C:\ Users \ MinTeckNG \ Desktop \ TwilightAdventure \ Debug \ TwilightAdventure.exp 1> LoadingMap.obj:错误LNK2019:未解析的外部符号“public:__thiscall Json :: Reader :: Reader(void)”(?? 0Reader @Json @@ QAE @ XZ)在函数“public:void __thiscall LoadingMap ::”中引用ReadJsonFileTest(void)“(?ReadJsonFileTest @ LoadingMap @@ QAEXXZ) 1> C:\ Users \ MinTeckNG \ Desktop \ TwilightAdventure \ Debug \ TwilightAdventure.exe:致命错误LNK1120:1未解析的外部 ==========构建:0成功,1个失败,0个最新,0个跳过==========
error picture lnk2019未解析的外部符号
{
"actors": [
{
"name": "Ground",
"pos": {
"x": 2592.0,
"y": 96.0
}
},
{
"name": "Grass",
"pos": {
"x": 2656.0,
"y": 96.0
}
}
}
我的代码
#include "LoadingMap.h"
#include <fstream>
LoadingMap::LoadingMap(void)
{
}
LoadingMap::~LoadingMap(void)
{
}
/*const char *LoadingMap::GetFileName(int stage, int difficulties)
{
char a = '0';
const char *ptr = &a;
return ptr;
}*/
/*void LoadingMap::ReadJsonFile(const char *filename)
{
}*/
void LoadingMap::ReadJsonFileTest()
{
std::ifstream ifs("1-1-0.json");
Json::Reader reader;
//Json::Value obj;
//reader.parse(ifs, obj);
//std::cout << "Object type: " << obj["name"].asString() << std::endl;
//const Json::Value& pos = obj["pos"];
//std::cout << " x: " << pos[0]["x"].asUInt();
//std::cout << " y: " << pos[1]["y"].asUInt();
}
我的头文件
#pragma once
#include <iostream>
#include <fstream>
#include <json/json.h>
class LoadingMap
{
public:
LoadingMap(void);
~LoadingMap(void);
//const char *GetFileName(int stage, int difficulties);
//void ReadJsonFile(const char *filename);
void ReadJsonFileTest();
private:
};
代码主要是什么,没有任何实现,我尝试按照教程修改。
答案 0 :(得分:0)
改为quickjson而不是jsoncpp。现在一切似乎还可以。