mosquitto 源码make安装报错config.h:86:12: fatal error: cjson/cJSON.h: No such file or directory

mosquitto 源码make安装报错config.h:86:12: fatal error: cjson/cJSON.h: No such file or directory

cc -Wall -ggdb -O2 -Wconversion -Wextra -I../../include -I../../ -I../../lib -I../../src -I../../deps -DWITH_BROKER -DWITH_PERSISTENCE -c stubs.c -o stubs.o
cc -Wall -ggdb -O2 -Wconversion -Wextra -I../../include -I../../ -I../../lib -I../../src -I../../deps -DWITH_BROKER -DWITH_PERSISTENCE -c ../../lib/time_mosq.c -o time_mosq.o
cc -Wall -ggdb -O2 -Wconversion -Wextra -I../../include -I../../ -I../../lib -I../../src -I../../deps -DWITH_BROKER -DWITH_PERSISTENCE -c ../../src/topic_tok.c -o topic_tok.o
cc -Wall -ggdb -O2 -Wconversion -Wextra -I../../include -I../../ -I../../lib -I../../src -I../../deps -DWITH_BROKER -DWITH_PERSISTENCE -c ../../lib/utf8_mosq.c -o utf8_mosq.o
cc db_dump.o print.o memory_mosq.o memory_public.o packet_datatypes.o packet_mosq.o persist_read.o persist_read_v234.o persist_read_v5.o property_mosq.o send_disconnect.o stubs.o time_mosq.o topic_tok.o utf8_mosq.o -o mosquitto_db_dump
make[2]: Leaving directory '/etc/mosquitto/src/mosquitto-2.0.15/apps/db_dump'
make[2]: Entering directory '/etc/mosquitto/src/mosquitto-2.0.15/apps/mosquitto_ctrl'
cc -I../mosquitto_passwd -DWITH_CJSON  -I. -I../../ -I../../include -I../../src -I../../lib -DWITH_TLS -Wall -ggdb -O2 -Wconversion -Wextra -DVERSION=\""2.0.15\"" -c mosquitto_ctrl.c -o mosquitto_ctrl.o
In file included from mosquitto_ctrl.c:19:
../../config.h:86:12: fatal error: cjson/cJSON.h: No such file or directory
   86 | #  include 
      |            ^~~~~~~~~~~~~~~
compilation terminated.
make[2]: *** [Makefile:51: mosquitto_ctrl.o] Error 1
make[2]: Leaving directory '/etc/mosquitto/src/mosquitto-2.0.15/apps/mosquitto_ctrl'
make[1]: *** [Makefile:9: all] Error 2
make[1]: Leaving directory '/etc/mosquitto/src/mosquitto-2.0.15/apps'
make: *** [Makefile:66: mosquitto] Error 2

任意目录下
git clone https://github.com/DaveGamble/cJSON.git

Cloning into 'cJSON'...
fatal: unable to access 'https://github.com/DaveGamble/cJSON.git/': GnuTLS recv error (-110): The TLS connection was non-properly terminated.


网络有点问题,重试
git clone https://github.com/DaveGamble/cJSON.git

Cloning into 'cJSON'...
remote: Enumerating objects: 4545, done.
remote: Total 4545 (delta 0), reused 0 (delta 0), pack-reused 4545
Receiving objects: 100% (4545/4545), 2.45 MiB | 4.75 MiB/s, done.
Resolving deltas: 100% (3026/3026), done.



输入make回车

gcc -std=c89 -c -fPIC -pedantic -Wall -Werror -Wstrict-prototypes -Wwrite-strings -Wshadow -Winit-self -Wcast-align -Wformat=2 -Wmissing-prototypes -Wstrict-overflow=2 -Wcast-qual -Wc++-compat -Wundef -Wswitch-default -Wconversion -fstack-protector-strong cJSON.c
gcc -std=c89 -shared -o libcjson.so.1.7.15 cJSON.o -Wl,-soname=libcjson.so.1
ln -s libcjson.so.1.7.15 libcjson.so.1
ln -s libcjson.so.1 libcjson.so
gcc -std=c89 -c -fPIC -pedantic -Wall -Werror -Wstrict-prototypes -Wwrite-strings -Wshadow -Winit-self -Wcast-align -Wformat=2 -Wmissing-prototypes -Wstrict-overflow=2 -Wcast-qual -Wc++-compat -Wundef -Wswitch-default -Wconversion -fstack-protector-strong cJSON_Utils.c
gcc -std=c89 -shared -o libcjson_utils.so.1.7.15 cJSON_Utils.o cJSON.o -Wl,-soname=libcjson_utils.so.1
ln -s libcjson_utils.so.1.7.15 libcjson_utils.so.1
ln -s libcjson_utils.so.1 libcjson_utils.so
ar rcs libcjson.a cJSON.o
ar rcs libcjson_utils.a cJSON_Utils.o
gcc -std=c89 -fPIC -pedantic -Wall -Werror -Wstrict-prototypes -Wwrite-strings -Wshadow -Winit-self -Wcast-align -Wformat=2 -Wmissing-prototypes -Wstrict-overflow=2 -Wcast-qual -Wc++-compat -Wundef -Wswitch-default -Wconversion -fstack-protector-strong cJSON.c test.c  -o cJSON_test -lm -I.

 输入sudo make install回车
 

mkdir -p /usr/local/lib /usr/local/include/cjson
cp -a cJSON.h /usr/local/include/cjson
cp -a libcjson.so libcjson.so.1 libcjson.so.1.7.15 /usr/local/lib
cp -a cJSON_Utils.h /usr/local/include/cjson
cp -a libcjson_utils.so libcjson_utils.so.1 libcjson_utils.so.1.7.15 /usr/local/lib

然后再去编译mosquitto就正常了

参考:【学习笔记】Mosquitto 基础安装使用_mosquitto下载_dadalaohua的博客-CSDN博客

你可能感兴趣的:(c++)