zoukankan      html  css  js  c++  java
  • json ubuntu下安装

    1.首先安装scons

    scons是linux下的自动构建工具,类似cmake。

    下载地址
    wget http://prdownloads.sourceforge.net/scons/scons-2.2.0.tar.gz

    解压并安装之,如下

    tar zxvf scons-2.2.0.tar.gz
    cd scons-2.2.0
    sudo python setup.py install

    然后配置环境变量,sudo vi /etc/profile

    #json environment set
    export MYSCONS=/home/gary/localization_ws/json/scons-2.2.0
    export SCONS_LIB_DIR=$MYSCONS/engine
    export PATH=$MYSCONS:$SCONS_LIB_DIR:$PATH

    退出后,执行source /etc/profile

    jsoncpp的安装

    先下载之http://sourceforge.net/projects/jsoncpp/files/

    tar -zxf jsoncpp-src-0.5.0.tar.gz
    cd jsoncpp-src-0.5.0
    scons platform=linux-gcc

    然后,将编译好的静态库和动态库文件拷贝考/usr/local/lib下

    sudo cp libs/linux-gcc-5.4.0/libjson_linux-gcc-5.4.0_libmt.so /usr/local/lib/

    sudo cp libs/linux-gcc-5.4.0/libjson_linux-gcc-5.4.0_libmt.a /usr/local/lib/
    将头文件拷贝到/usr/local/include下面

    sudo cp -r include/json/ /usr/local/include/

    下面进行测试

    #include <iostream>
    #include <json/json.h>
    
    using namespace std;
    
    int main()
    {
            Json::Value root;
            Json::FastWriter fast;
            root["DateTime"] = ("23");
            root["Name"] = ("hello");
            root["class"] = ("12");
            cout << fast.write(root) << endl;
            return 0;
    }

    编译之g++ test.cpp -o test /usr/local/lib/libjson_linux-gcc-5.4.0_libmt.a

    执行./test

    {"DateTime":"23","Name":"hello","class":"12"}

    done!

    ubuntu C++soncpp工具库解析 json环境搭建(转) soncpp工具库解析JSON范例(分PC端和ARM设备运行两种)

     https://www.douban.com/note/619750040/

    一些简单的例子

    https://blog.csdn.net/ccfxue/article/details/51224274

  • 相关阅读:
    HDU
    Groundhog Build Home
    The Moving Points
    Problem I. Count
    Problem E. TeaTree
    树的启发式合并
    Special Segments of Permutation
    网络流24题
    2015-2016 Northwestern European Regional Contest (NWERC 2015)
    The 2018 ACM-ICPC Asia Beijing Regional Contest
  • 原文地址:https://www.cnblogs.com/gary-guo/p/10081237.html
Copyright © 2011-2022 走看看