Json---using Jsoncpp under Linux

Source: Internet
Author: User
Tags locale

First, install the SCons

: Http://sourceforge.net/projects/scons/files/scons/2.1.0/scons-2.1.0.tar.gz/download

Decompression: TAR-ZVXF scons-2.1.0.tar.gz

Go to unzip directory scons-2.1.0 execute command:

sudo python setup.py install

Second, installation Jsoncpp

: http://sourceforge.net/projects/jsoncpp/

Decompression: TAR-ZVXF jsoncpp-src-0.5.0.tar.gz

Go to the Jsoncpp decompression directory and execute the command:

sudo scons PLATFORM=LINUX-GCC

Copy the JSON folder under the/jsoncpp-src-0.5.0/include/directory to the/usr/local/include/

Copy the LIBJSON_LINUX-GCC-4.9.1_LIBMT.A under the JSONCPP-SRC-0.5.0/LIBS/LINUX-GCC-4.9.1/directory to/usr/local/lib/, and for ease of use, Rename it to Libjson.a

Third, the use of LIBJSON.A

Makefile

Target=main

inc=-i/usr/local/include/libmongoc-1.0-i/usr/local/include/libbson-1.0/-i/usr/local/include/json
Lib_path=-l/usr/local/lib
lib=-lmongoc-1.0-lbson-1.0 /usr/local/lib/libjson.a

Cflags:=-wall-g-o0-lrt-rdynamic-fpic-wl,-rpath=./$ (INC) $ (Lib_path)
cppflags:=$ (CFLAGS)

src=$ (Shell Echo *.cpp)
obj=$ (Patsubst%.cpp,%.o,$ (SRC))

All: $ (TARGET)

$ (TARGET): $ (OBJ)
$ (CXX) $^ $ (CFLAGS) $ (LIB)-o [email protected]

Clean
Rm-f $ (OBJ)
Rm-f $ (TARGET)

  

JSON syntax is visible: http://www.cnblogs.com/SZxiaochun/p/5866401.html Demo

Iv. Compile Error

Error:missing binary operator before token "("

/usr/include/wchar.h:104:1: Error: ' __begin_namespace_c99 ' does not name a type
/usr/include/wchar.h:107:1: Error: ' __end_namespace_c99 ' does not name a type
/usr/include/wchar.h:135:1: Error: ' __END_NAMESPACE_STD ' does not name a type
/usr/include/wchar.h:149:6: error:expected initializer before ' __throw '
/usr/include/wchar.h:153:39:error:expected initializer before ' __throw '
/usr/include/wchar.h:157:6: error:expected initializer before ' __throw '
/usr/include/wchar.h:161:6: error:expected initializer before ' __throw '

/usr/include/c++/4.6/cwchar:143:11:error: ':: BTOWC ' have not been declared
/usr/include/c++/4.6/cwchar:144:11:error: ':: FGETWC ' have not been declared
/usr/include/c++/4.6/cwchar:148:11:error: ':: Fwide ' have not been declared
/usr/include/c++/4.6/cwchar:149:11:error: ':: fwprintf ' have not been declared
/usr/include/c++/4.6/cwchar:150:11:error: ':: fwscanf ' have not been declared

/usr/include/c++/4.6/cwchar:215:55:error:invalid conversion from ' const wchar_t* ' to ' wchar_t* ' [-fpermissive]
/usr/include/c++/4.6/cwchar:214:3: error:initializing argument 1 of ' wchar_t* std::wcschr (wchar_t*, wchar_t) ' [-fpermi Ssive]

/usr/include/locale.h:at Global scope:
/usr/include/locale.h:32:1: Error: ' __begin_decls ' does not name a type
/usr/include/locale.h:125:65:error:expected initializer before ' __throw '
/usr/include/locale.h:128:40:error:expected initializer before ' __throw '
/usr/include/locale.h:130:1: Error: ' __END_NAMESPACE_STD ' does not name a type

......

  Reason:

There is a features.h file in the Jsoncpp, there is also a file with the same name under/usr/include, so problems such as file dependency order occur, and once confused, a bunch of errors are reported.

  Workaround:

Rename the Jsoncpp features.h , and then Json.h and reader.h to reference it, in the corresponding position to replace the new file name is OK.

  

Json---using Jsoncpp under Linux

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.