解決Ubuntu16.04 fatal error: json/json.h: No such file or directory


參考博客

錯誤產生

安裝json-c庫之后,根據GitHub上面的readme文件鏈接到json-c庫時出現以下錯誤:

SDMBNJson.h:9:23: fatal error: json/json.h: No such file or directory
 #include <json/json.h>
                       ^
compilation terminated.

貼出readme:

Linking to `libjson-c`
----------------------

If your system has `pkgconfig`,
then you can just add this to your `makefile`:

\```make
CFLAGS += $(shell pkg-config --cflags json-c)
LDFLAGS += $(shell pkg-config --libs json-c)
\ ```

Without `pkgconfig`, you would do something like this:

\```make
JSON_C_DIR=/path/to/json_c/install
CFLAGS += -I$(JSON_C_DIR)/include/json-c
LDFLAGS+= -L$(JSON_C_DIR)/lib -ljson-c
\```

可是,按照readme上面的做法還是無法解決問題。

解決方案

在Linux系統中,/usr/include/ 是C/C++等的頭文件放置處,當使用源代碼方式安裝某些數據時,會使用到其中很多文件。因此將編譯安裝完成的json-c文件夾改名為“json”放在/usr/include/目錄下,即可解決:

cd /usr/include
sudo mkdir json
sudo cp /usr/local/include/json-c/* /usr/include/json/


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM