Linux下编译安装JsonCpp(1.9.4)最新版本

前言

在网上找了很多在linux上使用jsoncpp的教程,都是0.5版本的,最后考虑了一下还是用新版本的吧,发个文章记录下编译过程同时帮助一些需要用到新版本的人。

环境搭建

新版本的JsonCpp不再支持scons编译,需要用CMake编译,同时CMake版本必须是3.8以上的,我安装的是3.12.2版本。

CMake安装过程参考文章:
链接: VMware+ubuntu+linux下载及安装(win10) --7. Ubuntu 18.0 中安装cmake 3.12.2.


安装JsonCpp

1、下载

使用wget下载文件,命令如下:

wget https://github.com/open-source-parsers/jsoncpp/archive/master.tar.gz

    
    
  • 1
2、解压

解压文件:

tar zxvf master.tar.gz

    
    
  • 1
3、执行CMake

进入解压后的文件夹内,执行cmake

cd jsoncpp-master/
cmake CMakeLists.txt

    
    
  • 1
  • 2

cmake执行截图

执行完成之后你会发现生成了一个CMakeFile的文件夹,同时
会生成一个Makefile文件。
执行完cmake后的文件目录

4、执行make

执行make进行编译

make

    
    
  • 1

编译完成
编译完成后截图

5、库与头文件

编译完成后解压文件目录下的lib文件夹下存放了生成的库

库目录
编译完成后解压文件目录下的include/json文件夹下存放了头文件

头文件目录

6、布置环境

将生成的库与头文件布置到linux下

make install

    
    
  • 1

布置环境


总结

emmm,写完之后突然觉得过程好简单…希望能帮到需要的朋友。
另外给大家提供一个jsoncpp使用方法的文章,里面该有的都有:
C++ Builder 生成 json,Json::StreamWriterBuilder 参数详解.


文章知识点与官方知识档案匹配,可进一步学习相关知识
CS入门技能树Linux入门初识Linux 8595 人正在系统学习中

**方法二:**

######################################################

jsoncpp should not be configured & built in the jsoncpp source directory

You must run cmake in a build directory.

For example:

mkdir jsoncpp-Sandbox ; cd jsoncpp-sandbox

git clone https://github.com/open-source-parsers/jsoncpp.git # or download & unpack the source tarball

mkdir jsoncpp-build

this will create the following directory structure

jsoncpp-Sandbox

±-jsoncpp

±-jsoncpp-build

Then you can proceed to configure and build

by using the following commands

cd jsoncpp-build

cmake …/jsoncpp # or ccmake, or cmake-gui

make

NOTE: Given that you already tried to make an in-source build

CMake have already created several files & directories

in your source tree. run ‘git status’ to find them and

remove them by doing:

cd jsoncpp-Sandbox/jsoncpp

git clean -n -d

git clean -f -d

git checkout –

######################################################

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值