libjson-cコンパイルとインストール

2525 ワード

json-cトップページ:https://github.com/json-c/json-c/wiki
0.依存条件
本稿ではcentosシステムを採用するが,yumコマンドも必要である.
#   
gcc, clang, or another C compiler
#cmake
cmake>=2.8, >=3.16 recommended
#      ,   doxygen
To generate docs you'll also need:
doxygen>=1.8.13

If you are on a relatively modern system, you'll likely be able to install the prerequisites using your OS's packaging system.

#Install using yum (e.g. CentOs 7.6)
$ yum install -y git
$ yum install -y cmake
$ yum install -y doxygen  # optional
$ yum install -y valgrind # optional

1.ソースのダウンロード
公式Gibhubダウンロードアドレス:https://github.com/json-c/json-c/releases
#git clone           release
$ git clone [email protected]:json-c/json-c.git
$ git checkout json-c-0.14-20200419

#      tar 
$ wget https://github.com/json-c/json-c/archive/json-c-0.14-20200419.tar.gz -O json-c.tar.gz
$ tar zxvf json-c.tar.gz
$ mv json-c-json-c-0.14-20200419 json-c

2.コンパイルインストール
#cmake       
$ mkdir json-c-build && cd json-c-build
$ cmake ../json-c

次にコンパイルインストールを実行します
$ make
$ make test
$ make USE_VALGRIND=0 test   # optionally skip using valgrind
$ make install