解決Ubuntu16.04 fatal error: json/json.h: No such file or directory
阿新 • • 發佈:2018-11-08
錯誤產生
安裝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/