Linux jsoncpp安装与使用

  1. 安装scons
下载地址 http://prdownloads.sourceforge.NET/scons/scons-2.2.0.tar.gz
 $ wget http://prdownloads.sourceforge.NET/scons/scons-2.2.0.tar.gz
 $ cd scons-2.2.0
 $ python setup.py install
  1. 安装jsoncpp
	下载地址: https://sourceforge.net/projects/jsoncpp/files/latest/download?_test=goal
	$ cd jsoncpp
	$ scons platform=linux-gcc
	$ mv /libs/linux-gccxxxxxxxx_libmt.so   /usr/local/lib
	$ ln /usr/local/lib/linux-gccxxxxxxxx_libmt.so /usr/local/lib/libjsoncpp.so
	$ mv include/json /usr/local/include
	$ ldconfig
	$ ./bin/linxuxxxxxx/test_lib_json # 测试
	
	Testing ValueTest/size: OK
	Testing ValueTest/isObject: OK
	Testing ValueTest/isArray: OK
	Testing ValueTest/isBool: OK
	Testing ValueTest/isInt: OK
	Testing ValueTest/isUInt: OK
	Testing ValueTest/isDouble: OK
	Testing ValueTest/isString: OK
	Testing ValueTest/isNull: OK
	All 9 tests passed
  1. 编写jsoncpp.pc
$ touch /usr/local/lib/pkgconfig/jsoncpp.pc    # pkg-config path
$ vim /usr/local/lib/pkgconfig/jsoncpp.pc
编辑并保存
libdir=/usr/local/lib   // .so path
includedir=/usr/local/include/json  // header file path 
Name: jsoncpp 
Description: jsoncpp description
Version: json version
Libs: -L${libdir} -ljsoncpp
Cflags: -I{includedir}

$ pkg-config --cflags --libs jsoncpp

你可能感兴趣的:(C++,linux,jsoncpp,c++)