Mryqu's Notes


  • 首页

  • 搜索
close

[C++] Compile JsonCpp library using CMake

时间: 2017-03-23   |   分类: C++     |   阅读: 112 字 ~1分钟

本文为升级JsonCpp库操作过程的备份笔记。

Linux/Unix平台

下载JsonCpp

从JsonCpp releases页面可知,当前最高版本为1.8.0。

wget https://github.com/open-source-parsers/jsoncpp/archive/1.8.0.tar.gz
tar xzvf 1.8.0.tar.gz
cd jsoncpp-1.8.0
mkdir build/release

升级gcc

这里我选择使用gcc 5:

sudo add-apt-repository ppa:ubuntu-toolchain-r/test
sudo apt-get update
sudo apt-get install gcc-5 g++-5

sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-5 1
sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-5 1

Linux: gcc version

升级cmake

JsonCpp 1.8.0要求cmake>=3.1

sudo apt-get install software-properties-common
sudo add-apt-repository ppa:george-edison55/cmake-3.x
sudo apt-get update

sudo apt-get upgrade cmake

Linux: cmake version

编译JsonCpp

cmake -DCMAKE_BUILD_TYPE=release -DBUILD_STATIC_LIBS=ON -DBUILD_SHARED_LIBS=OFF -DARCHIVE_INSTALL_DIR=. -G "Unix Makefiles" ../..
make

Linux: build jsoncpp

Windows平台

准备环境

首先下载JsonCpp 1.8.0源码,并解压缩。我的机器已经部署了VS2013和CMake。 Windows: cmake version

编译JsonCpp

cmake -DBUILD_STATIC_LIBS=ON -DBUILD_SHARED_LIBS=OFF -G "Visual Studio 12 2013 Win64" ..
cmake --build . --config Release

Windows: cmake GenBuildFile Windows: build jsoncpp Windows: check lib 注:如果编译32位库,则上述过程改用下列命令

cmake -DBUILD_STATIC_LIBS=ON -DBUILD_SHARED_LIBS=OFF -G "Visual Studio 12 2013" ..

参考


CMake WiKi
CMake command manual
CMake Useful Variables
g++ man page

标题:[C++] Compile JsonCpp library using CMake
作者:mryqu
声明: 本博客所有文章除特别声明外,均采用 CC BY-NC-SA 3.0 CN 许可协议。转载请注明出处!

#jsoncpp# #cmake# #gcc# #linux# #windows# #C++#
[MySQL] 将空返回值转换成NULL
[C++] Build JsonCpp library in Linux platform
  • 文章目录
  • 站点概览

Programmer & Architect

662 日志
27 分类
1472 标签
GitHub Twitter FB Page
    • Linux/Unix平台
    • Windows平台
    • 参考
© 2009 - 2023 Mryqu's Notes
Powered by - Hugo v0.120.4
Theme by - NexT
0%