一、安装 scons

  下载地址:http://sourceforge.net/projects/scons/files/scons/2.1.0/scons-2.1.0.tar.gz/download

  百度网盘:链接:https://pan.baidu.com/s/1tW57c9s3iCeoDi4OIDyEPQ 密码:2wd5

  解压:tar -zvxf scons-2.1.0.tar.gz

  进入到解压目录scons-2.1.0 执行命令:

    sudo python setup.py install

二、安装 Jsoncpp

  下载地址:http://sourceforge.net/projects/jsoncpp/

  百度网盘:链接:https://pan.baidu.com/s/1tW57c9s3iCeoDi4OIDyEPQ 密码:2wd5

  解压:tar -zvxf jsoncpp-src-0.5.0.tar.gz

  进入到jsoncpp解压目录下,执行命令:

    sudo scons platform=linux-gcc

  将/jsoncpp-src-0.5.0/include/目录下的json文件夹拷贝到 /usr/local/include/

  将jsoncpp-src-0.5.0/libs/linux-gcc-4.9.1/目录下的libjson_linux-gcc-4.9.1_libmt.a 拷贝到 /usr/local/lib/ 下,并为了方便使用,将其重命名为libjson.a

三、使用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 $@

clean:
rm -f $(OBJ)
rm -f $(TARGET)

  

json语法 可见:http://www.cnblogs.com/SZxiaochun/p/5866401.html 的 Demo

四、编译报错  

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’ has not been declared
/usr/include/c++/4.6/cwchar:144:11: error: ‘::fgetwc’ has not been declared
/usr/include/c++/4.6/cwchar:148:11: error: ‘::fwide’ has not been declared
/usr/include/c++/4.6/cwchar:149:11: error: ‘::fwprintf’ has not been declared
/usr/include/c++/4.6/cwchar:150:11: error: ‘::fwscanf’ has 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)’ [-fpermissive]

/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

......

  原因:

    jsoncpp中有一个features.h文件,在/usr/include下也有一个同名的文件,所以就出现文件依赖顺序等问题,一旦搞混,就报了一堆错

  解决方法:

    把jsoncpp的 features.h重命名,然后json.h与reader.h要引用它,在相应的位置换成新的文件名字就ok了。

  

Json---Linux下使用Jsoncpp的更多相关文章

  1. linux下使用C++ Json库

    安装Json库 1.下载JsonCpphttp://sourceforge.net/projects/jsoncpp/files/ 2.下载sconshttp://sourceforge.net/pr ...

  2. jsoncpp在Windows和Linux下的安装

    Windows下: 参考这个网站,没什么问题,注意MTd这些选对就行了. http://www.cppblog.com/wanghaiguang/archive/2013/12/26/205020.h ...

  3. Linux下处理JSON的命令行工具:jq---安装

    转自:https://blog.csdn.net/Sunny_much/article/details/50668871      JSON是前端编程经常用到的格式.Linux下也有处理处理JSON的 ...

  4. json ubuntu下安装

    1.首先安装scons scons是linux下的自动构建工具,类似cmake. 下载地址wget http://prdownloads.sourceforge.net/scons/scons-2.2 ...

  5. NodeJs在Linux下使用的各种问题

    环境:ubuntu16.04 ubuntu中安装NodeJs 通过apt-get命令安装后发现只能使用nodejs,而没有node命令 如果想避免这种情况请看下面连接的这种安装方式: 拓展见:Linu ...

  6. Linux下安装MongoDB

    MongoDB是一个C++编写的基于分布式文件存储的数据库,是一个介于关系和非关系之间的数据库,当然也属于NoSQL的行列,存储方式和Redis类似,是json格式的kav-value存储方式,只是R ...

  7. Linux下MongoDB服务安装

    Linux下MongoDB服务安装 MongoDB是一个基于分布式文件存储的数据库.由C++语言编写.旨在为WEB应用提供可扩展的高性能数据存储解决方案.MongoDB是一个介于关系数据库和非关系数据 ...

  8. 浅谈linux 下,利用Nginx服务器代理实现ajax跨域请求。

    ajax跨域请求对于前端开发者几乎在任何一个项目中都会用到,众所周知,跨域请求有三种方式: jsonp; XHR2 代理: jsonp: 这种应该是开发中是使用的最多的,最常见的跨域请求方法,其实aj ...

  9. MongoDB学习笔记—Linux下搭建MongoDB环境

    1.MongoDB简单说明 a MongoDB是由C++语言编写的一个基于分布式文件存储的开源数据库系统,它的目的在于为WEB应用提供可扩展的高性能数据存储解决方案. b MongoDB是一个介于关系 ...

  10. linux 下cmake 编译 ,调用,调试 poco 1.6.0 小记

    上篇文章 小记了: 关于 Poco::TCPServer框架 (windows 下使用的是 select模型) 学习笔记. http://www.cnblogs.com/bleachli/p/4352 ...

随机推荐

  1. ES monitoring

    https://www.quora.com/What-is-the-best-monitoring-tool-for-Elasticsearch-I-also-want-log-monitoring- ...

  2. 每日英语:American Cities May Have Hit 'Peak Office'

    Despite some hype and a few regional exceptions, the construction of office towers and suburban offi ...

  3. 每日英语:The Risks of Big Data for Companies

    Big data. It's the latest IT buzzword, and it isn't hard to see why. The ability to parse more infor ...

  4. Python:sitecustomize 和 usercustomize

    Python提供了两个hook用于定制Python:sitecustomize 和 usercustomize,首先需要查看site包目录, 然后就可以在此目录下创建usercustomize.py文 ...

  5. HBase scan setBatch和setCaching的区别【转】

    转自:http://blog.csdn.net/caoli98033/article/details/44650497 HBase的查询实现只提供两种方式: 1.按指定RowKey获取唯一一条记录,g ...

  6. ffmpeg转码参数设置

    ffmpeg用了很久了,也没有想写点什么. 刚接触ffmpeg也是有大量的不理解的地方,不过慢慢的了解多了基本上都是可以使用的. 本文主要介绍如何使用ffmpeg.exe进行转码.编译好的ffmpeg ...

  7. Centos7 ss搭建

    1.安装pip Pip 是 Python 的包管理工具,下载ss十分方便,但是centos是没有pip的,我们需要安装一个. yum install python-setuptools & e ...

  8. H3C交换机配置的备份与恢复(TFTP方法)

    局域网维护中,有时候我们需要对网络设备的配置进行备份与还原. 相信有很多网管员备份配置都是采用display current命令查询当前设备运行配置信息,然后采用ctrl+c,ctrl+v的方式将信息 ...

  9. 在PL/SQL中调用存储过程--oracle

    在oracle10中写好了存储过程,代码如下: CREATE OR REPLACE Procedure Proc_Insert ( sName in varchar2, sAge in int, sE ...

  10. MATLAB 2016b 切换回英文版

    原因: 中文下不能使用等间距字体.因为等间距字体都是英文字体,报错信息又是中文的,所以这时候报错就全是乱码.如果改成中文字体,又不是等间距的了,看着瞎眼. 方法: Preferences->Ge ...