1. Download Tool
Jsoncpp
Http://sourceforge.net/projects/jsoncpp/files/
Scons
Http://sourceforge.net/projects/scons/files/scons/2.1.0/scons-2.1.0.tar.gz
Note:
① Installation jsoncpp download required jsoncpp and scon python
② scons is a tool with functions and GNU make Same as make It's much simpler. scons Yes python tool, you must install python .
2. InstallScons
①Extract
Tar-zxvf scons-2.0.1.tar.gz
②Set Environment Variables
Export myscons = decompressed path
Export scons_lib_dir = $ myscons/Engine
③SwitchJsoncppAnd run the following command:
Python $ myscons/script/scons platform = Linux-gcc
④Generate static and dynamic library files
InJsoncpp-src-0.5.0/libs/linux-gcc-4.1.2Directory
Libjson_linux-gcc-4.4.4_libmt.a
Libjson_linux-gcc-4.4.4_libmt.so
Mkdir/usr/include/jsoncpp
⑤Copy two library filesJsoncppDirectory
3. Example
Rename the static libraryLibjson.
Example
View code
# Include " JSON/JSON. h "
# Include <String >
# Include <iostream>
Using Namespace STD;
Int Main ()
{
String Test = " {\ "ID \": 1, \ "Name \": \ "Kurama \"} " ;
JSON: reader;
JSON: Value value;
If (Reader. parse (test, value ))
{
If (! Value [ " ID " ]. Isnull ())
{
Cout <value [ " ID " ]. Asint () <Endl;
Cout <value [ " Name " ]. Asstring () <Endl;
}
}
Return 0 ;
}
Compile:G ++-O json_t json_t2.cpp/usr/include/JSON/libjson.
Reference
【1]SconsOfficial Website
Http://www.scons.org/
【2] Installation Reference
Http://blog.csdn.net/zxkurama/article/details/6543552
Http://hi.baidu.com/%B4% AB %CB%B5%D6%D0%B5%C4%C8%CC%D5%DF%C3%A8/blog/item/a6eb970c98a644d67acbe15a.html