4. Install jsoncpp

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.