使用eclipse编译jsonCpp

1.自已废了很大劲安装使用vs2010,结果还是无法编译jsoncpp,估计是太新的,很多语法报错

 

2.

使用eclipse编译jsonCpp_第1张图片

使用eclipse编译jsonCpp_第2张图片

使用eclipse编译jsonCpp_第3张图片

使用eclipse编译jsonCpp_第4张图片

 

使用eclipse编译jsonCpp_第5张图片

 

 

 

 

3.测试

 

#include 
#include 
#include 

using namespace std;

int main(int argc, char **argv) {
	std::string strValue = " {\"key1\":\"value1\",\"array\":[ {\"key2\":\"value2\"},{\"key2\":\"value3\"},{\"key2\":\"value4\"}]}";

	Json::Reader reader;
	Json::Value value;

	if (reader.parse(strValue, value)) {
		std::string out = value["key1"].asString();
		std::cout << out << std::endl;
		const Json::Value arrayObj = value["array"];

		for (int i = 0; i < arrayObj.size(); i++)
		{
			out = arrayObj[i]["key2"].asString();
			std::cout << out;
			if (i != arrayObj.size() - 1)
				std::cout << std::endl;
		}

	}
	while(1);
	return 1;
}


添加动态lib

使用eclipse编译jsonCpp_第6张图片

整个过程中我们使用eclipse帮我们生成动态库,当是你必须知道怎么去编写makefile,这个你才知道如何去使用eclipse

 

你可能感兴趣的:(C++笔记)