04-Ubuntu 22.04LTS安装 json (jsoncpp/jsonc)

发布于:2024-07-25 ⋅ 阅读:(275) ⋅ 点赞:(0)

1. jsoncpp安装指令

sudo apt-get install libjsoncpp-dev

1.1 验证

# 检查是否安装成功
ls /usr/include/jsoncpp/json/

1.2. 使用

#include <jsoncpp/json/json.h>

1.3. 编译

g++ -ljsoncpp

2. jsonc安装指令

sudo aptitude install libjson-c-dev
---------------------------------------------------
The following NEW packages will be installed:
  libjson-c-dev{b}
0 packages upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
Need to get 60.4 kB of archives. After unpacking 291 kB will be used.
The following packages have unmet dependencies:
 libjson-c-dev : Depends: libjson-c5 (= 0.15-2build4) but 0.15-3~ubuntu1.22.04.2 is installed
The following actions will resolve these dependencies:

     Keep the following packages at their current version:
1)     libjson-c-dev [Not Installed]


---------------------------------------------------
Accept this solution? [Y/n/q/?] n
---------------------------------------------------
The following actions will resolve these dependencies:

     Downgrade the following packages:
1)     libjson-c5 [0.15-3~ubuntu1.22.04.2 (now) -> 0.15-2build4 (jammy)]


---------------------------------------------------
Accept this solution? [Y/n/q/?] y
---------------------------------------------------
The following packages will be DOWNGRADED:
  libjson-c5
The following NEW packages will be installed:
  libjson-c-dev
0 packages upgraded, 1 newly installed, 1 downgraded, 0 to remove and 0 not upgraded.
Need to get 93.7 kB of archives. After unpacking 291 kB will be used.

---------------------------------------------------
Do you want to continue? [Y/n/?] y
---------------------------------------------------
Get: 1 http://archive.ubuntu.com/ubuntu jammy/main amd64 libjson-c5 amd64 0.15-2build4 [33.3 kB]
Setting up libjson-c-dev (0.15-2build4) ...
Processing triggers for libc-bin (2.35-0ubuntu3.7) ...

2.2 验证

ls /usr/include/json-c/

2.2 使用

#include <json-c/json.h>

2.2 编译

g++ -ljson-c

网站公告

今日签到

点亮在社区的每一天
去签到