Json---Linux下使用Jsoncpp
一、安装 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的更多相关文章
- linux下使用C++ Json库
安装Json库 1.下载JsonCpphttp://sourceforge.net/projects/jsoncpp/files/ 2.下载sconshttp://sourceforge.net/pr ...
- jsoncpp在Windows和Linux下的安装
Windows下: 参考这个网站,没什么问题,注意MTd这些选对就行了. http://www.cppblog.com/wanghaiguang/archive/2013/12/26/205020.h ...
- Linux下处理JSON的命令行工具:jq---安装
转自:https://blog.csdn.net/Sunny_much/article/details/50668871 JSON是前端编程经常用到的格式.Linux下也有处理处理JSON的 ...
- json ubuntu下安装
1.首先安装scons scons是linux下的自动构建工具,类似cmake. 下载地址wget http://prdownloads.sourceforge.net/scons/scons-2.2 ...
- NodeJs在Linux下使用的各种问题
环境:ubuntu16.04 ubuntu中安装NodeJs 通过apt-get命令安装后发现只能使用nodejs,而没有node命令 如果想避免这种情况请看下面连接的这种安装方式: 拓展见:Linu ...
- Linux下安装MongoDB
MongoDB是一个C++编写的基于分布式文件存储的数据库,是一个介于关系和非关系之间的数据库,当然也属于NoSQL的行列,存储方式和Redis类似,是json格式的kav-value存储方式,只是R ...
- Linux下MongoDB服务安装
Linux下MongoDB服务安装 MongoDB是一个基于分布式文件存储的数据库.由C++语言编写.旨在为WEB应用提供可扩展的高性能数据存储解决方案.MongoDB是一个介于关系数据库和非关系数据 ...
- 浅谈linux 下,利用Nginx服务器代理实现ajax跨域请求。
ajax跨域请求对于前端开发者几乎在任何一个项目中都会用到,众所周知,跨域请求有三种方式: jsonp; XHR2 代理: jsonp: 这种应该是开发中是使用的最多的,最常见的跨域请求方法,其实aj ...
- MongoDB学习笔记—Linux下搭建MongoDB环境
1.MongoDB简单说明 a MongoDB是由C++语言编写的一个基于分布式文件存储的开源数据库系统,它的目的在于为WEB应用提供可扩展的高性能数据存储解决方案. b MongoDB是一个介于关系 ...
- linux 下cmake 编译 ,调用,调试 poco 1.6.0 小记
上篇文章 小记了: 关于 Poco::TCPServer框架 (windows 下使用的是 select模型) 学习笔记. http://www.cnblogs.com/bleachli/p/4352 ...
随机推荐
- iOS开发如何学习前端(1)
iOS开发如何学习前端(1) 我为何学前端?因为无聊. 概念 前端大概三大块. HTML CSS JavaScript 基本上每个概念在iOS中都有对应的.HTML请想象成只能拉Autolayout或 ...
- 【Android】Intent解读
Intent 的作用 Intent 是一个将要执行的动作的抽象的描述,一般来说是作为参数来使用,由Intent来协助完成android各个组件之间的通讯. 比如说调用startActivity()来启 ...
- script 页面在指定位置加载
<head> <script> function load(){window.location="#workspaces"} </script> ...
- jQuery之自定义datagrid控件
sldatagrid 效果: sldatagrid.js (function($) { function loadColumns(sldatagrid, columns) { $(sldatagrid ...
- mysql防止误删除的方法
为了防止在更新和删除的时候,没有写where条件而对全部数据进行操作,mysql提供了一个参数来防止此情况的发生 需要在启动mysql的时候,增加参数--i-am-a-dummy含义是我是新手,或者使 ...
- button上传替换file上传按钮,并显示图片缩略图,纯jsp操作
1.jsp代码 <div class="inputBox"> <span id="tu" <c:if test="${pd = ...
- [转]java中通过request获取路径中的不同信息
原文地址:http://blog.csdn.net/lv_shijun/article/details/40819859 aa为工程中的项目名 bb为webRoot下的文件夹 1.request.ge ...
- 【WPF】代码触发Button点击事件
先定义Button按钮并绑定事件. public void test() { Button btn = new Button(); btn.Click += Btn_Click; } private ...
- 使用 Easy Sysprep v4(ES4) 封装 Windows 7教程
总:1.装系统ctrl+shift+f3(administrator)2.备份系统,快速备份(pe下)3.安装补丁,软件(系统下),不装安全类软件,需激活的软件重装后还要激活4.系统备份(pe下叠 ...
- JVM垃圾回收算法(最全)
JVM垃圾回收算法(最全) 下面是JVM虚拟机运行时的内存模型: 1.方法区 Perm(永久代.非堆) 2.虚拟机栈 3.本地方法栈 (Native方法) 4.堆 5.程序计数器 1 首先的问题是:j ...