JsonCPP installation
Installation scons
Download :
http://sourceforge.net/projects/scons/files/scons/2.1.0/scons-2.1.0.tar.gz/download
Baidu network disk :
https://pan.baidu.com/s/ 1tW57c9s3iCeoDi4OIDyEPQ password: 2wd5
decompression :
tar -zvxf scons-2.1.0.tar.gz
Unzip into the directory scons-2.1.0, execute the command:
sudo python setup.py install
Installation JsonCPP
Download :
http://sourceforge.net/projects/jsoncpp/
decompression :
tar -zvxf jsoncpp-src-0.5.0.tar.gz
Into jsoncpp unzip directory, execute the command:
sudo scons platform=linux-gcc
Also the following two steps:
- The
/jsoncpp-src-0.5.0/include/
directoryjson
folder to the/usr/local/include/
next - The
jsoncpp-src-0.5.0/libs/linux-gcc-4.9.1/
directorylibjson_linux-gcc-4.9.1_libmt.a
copied to/usr/local/lib/
the next, and for convenience, to renamelibjsoncpp.a
This configuration has been completed, only need to add header files in your code: #include <json/json.h>
can be.
Testing procedures
Note: Specify the dynamic link library compiled in the address: -ljsoncpp
test program :
#include <iostream>
#include <string>
#include <json/json.h>
int main(void)
{
Json::Value root;
Json::FastWriter fast_writer;
root["REGION_ID"] = "600901";
root["DATA_TOTAL_NUM"] = "456278";
std::cout << fast_writer.write(root) << std::endl;
return 0;
}
Compile :
Note: link library -ljsoncpp
name and you copy to /usr/local/lib/
rename under the relevant
g++ -o JsonTest JsonTest.cpp -ljsoncpp
operation result:
$ ./JsonTest
{"DATA_TOTAL_NUM":"456278","REGION_ID":"600901"}
problem
If you can not find the wrong path, you need to edit the /etc/ld.so.conf
file, which records the dynamic library path using the compile-time compiler! Then we put /usr/local/lib
the path added to the end of the file on it!