构建 Mosquitto MQTT 身份验证插件问题
Building Mosquitto MQTT auth plugin issue
我需要 Mosquitto 的高级授权。我决定使用 mosquitto-auth-plug
但是,如果我按照 build instructions 我有错误:
$ make
Selected backends: JWT
Using mosquitto source dir: /mnt/c/Users/avkar/cleversky/mosquitto/mosquitto-1.4.15
OpenSSL install dir:
If you changed the backend selection, you might need to 'make clean' first
CFLAGS: -I/mnt/c/Users/avkar/cleversky/mosquitto/mosquitto-1.4.15/src/ -I/mnt/c/Users/avkar/cleversky/mosquitto/mosquitto-1.4.15/lib/ -fPIC -Wall -Werror -DBE_JWT -I/src -DDEBUG=1 -I/include
LDFLAGS: -L/mnt/c/Users/avkar/cleversky/mosquitto/mosquitto-1.4.15/lib/
LDADD: -lcurl -L/lib -lcrypto -lmosquitto
cc -I/mnt/c/Users/avkar/cleversky/mosquitto/mosquitto-1.4.15/src/ -I/mnt/c/Users/avkar/cleversky/mosquitto/mosquitto-1.4.15/lib/ -fPIC -Wall -Werror -DBE_JWT -I/src -DDEBUG=1 -I/include -c -o auth-plug.o auth-plug.c
cc -I/mnt/c/Users/avkar/cleversky/mosquitto/mosquitto-1.4.15/src/ -I/mnt/c/Users/avkar/cleversky/mosquitto/mosquitto-1.4.15/lib/ -fPIC -Wall -Werror -DBE_JWT -I/src -DDEBUG=1 -I/include -c -o base64.o base64.c
cc -I/mnt/c/Users/avkar/cleversky/mosquitto/mosquitto-1.4.15/src/ -I/mnt/c/Users/avkar/cleversky/mosquitto/mosquitto-1.4.15/lib/ -fPIC -Wall -Werror -DBE_JWT -I/src -DDEBUG=1 -I/include -c -o pbkdf2-check.o pbkdf2-check.c
cc -I/mnt/c/Users/avkar/cleversky/mosquitto/mosquitto-1.4.15/src/ -I/mnt/c/Users/avkar/cleversky/mosquitto/mosquitto-1.4.15/lib/ -fPIC -Wall -Werror -DBE_JWT -I/src -DDEBUG=1 -I/include -c -o log.o log.c
cc -I/mnt/c/Users/avkar/cleversky/mosquitto/mosquitto-1.4.15/src/ -I/mnt/c/Users/avkar/cleversky/mosquitto/mosquitto-1.4.15/lib/ -fPIC -Wall -Werror -DBE_JWT -I/src -DDEBUG=1 -I/include -c -o envs.o envs.c
cc -I/mnt/c/Users/avkar/cleversky/mosquitto/mosquitto-1.4.15/src/ -I/mnt/c/Users/avkar/cleversky/mosquitto/mosquitto-1.4.15/lib/ -fPIC -Wall -Werror -DBE_JWT -I/src -DDEBUG=1 -I/include -c -o hash.o hash.c
cc -I/mnt/c/Users/avkar/cleversky/mosquitto/mosquitto-1.4.15/src/ -I/mnt/c/Users/avkar/cleversky/mosquitto/mosquitto-1.4.15/lib/ -fPIC -Wall -Werror -DBE_JWT -I/src -DDEBUG=1 -I/include -c -o be-psk.o be-psk.c
cc -I/mnt/c/Users/avkar/cleversky/mosquitto/mosquitto-1.4.15/src/ -I/mnt/c/Users/avkar/cleversky/mosquitto/mosquitto-1.4.15/lib/ -fPIC -Wall -Werror -DBE_JWT -I/src -DDEBUG=1 -I/include -c -o backends.o backends.c
cc -I/mnt/c/Users/avkar/cleversky/mosquitto/mosquitto-1.4.15/src/ -I/mnt/c/Users/avkar/cleversky/mosquitto/mosquitto-1.4.15/lib/ -fPIC -Wall -Werror -DBE_JWT -I/src -DDEBUG=1 -I/include -c -o cache.o cache.c
cc -I/mnt/c/Users/avkar/cleversky/mosquitto/mosquitto-1.4.15/src/ -I/mnt/c/Users/avkar/cleversky/mosquitto/mosquitto-1.4.15/lib/ -fPIC -Wall -Werror -DBE_JWT -I/src -DDEBUG=1 -I/include -c -o be-jwt.o be-jwt.c
cc -I/mnt/c/Users/avkar/cleversky/mosquitto/mosquitto-1.4.15/src/ -I/mnt/c/Users/avkar/cleversky/mosquitto/mosquitto-1.4.15/lib/ -fPIC -Wall -Werror -DBE_JWT -I/src -DDEBUG=1 -I/include -L/mnt/c/Users/avkar/cleversky/mosquitto/mosquitto-1.4.15/lib/ -fPIC -shared -o auth-plug.so auth-plug.o base64.o pbkdf2-check.o log.o envs.o hash.o be-psk.o backends.o cache.o be-jwt.o -lcurl -L/lib -lcrypto -lmosquitto
/usr/bin/ld: cannot find -lmosquitto
collect2: error: ld returned 1 exit status
Makefile:160: recipe for target 'auth-plug.so' failed
make: *** [auth-plug.so] Error 1
有些 -lmosquitto
未找到。
我假设这是一个图书馆,但所有的图书馆都存在:
$ ls ../mosquitto-1.4.15/lib/
CMakeLists.txt logging_mosq.c memory_mosq.h mosquitto.h net_mosq.h read_handle_shared.c socks_mosq.c time_mosq.c util_mosq.c
cpp logging_mosq.h messages_mosq.c mosquitto_internal.h read_handle.c send_client_mosq.c socks_mosq.h time_mosq.h util_mosq.h
dummypthread.h Makefile messages_mosq.h mqtt3_protocol.h read_handle_client.c send_mosq.c srv_mosq.c tls_mosq.c will_mosq.c
linker.version memory_mosq.c mosquitto.c net_mosq.c read_handle.h send_mosq.h thread_mosq.c tls_mosq.h will_mosq.h
什么是 -lmosquitto
以及如何修复我的构建?
如评论中所述,
在尝试构建插件之前,您需要构建并安装 mosquitto(或安装预构建版本及其开发包)。
错误是因为ld找不到libmosquitto link反对
我需要 Mosquitto 的高级授权。我决定使用 mosquitto-auth-plug
但是,如果我按照 build instructions 我有错误:
$ make
Selected backends: JWT
Using mosquitto source dir: /mnt/c/Users/avkar/cleversky/mosquitto/mosquitto-1.4.15
OpenSSL install dir:
If you changed the backend selection, you might need to 'make clean' first
CFLAGS: -I/mnt/c/Users/avkar/cleversky/mosquitto/mosquitto-1.4.15/src/ -I/mnt/c/Users/avkar/cleversky/mosquitto/mosquitto-1.4.15/lib/ -fPIC -Wall -Werror -DBE_JWT -I/src -DDEBUG=1 -I/include
LDFLAGS: -L/mnt/c/Users/avkar/cleversky/mosquitto/mosquitto-1.4.15/lib/
LDADD: -lcurl -L/lib -lcrypto -lmosquitto
cc -I/mnt/c/Users/avkar/cleversky/mosquitto/mosquitto-1.4.15/src/ -I/mnt/c/Users/avkar/cleversky/mosquitto/mosquitto-1.4.15/lib/ -fPIC -Wall -Werror -DBE_JWT -I/src -DDEBUG=1 -I/include -c -o auth-plug.o auth-plug.c
cc -I/mnt/c/Users/avkar/cleversky/mosquitto/mosquitto-1.4.15/src/ -I/mnt/c/Users/avkar/cleversky/mosquitto/mosquitto-1.4.15/lib/ -fPIC -Wall -Werror -DBE_JWT -I/src -DDEBUG=1 -I/include -c -o base64.o base64.c
cc -I/mnt/c/Users/avkar/cleversky/mosquitto/mosquitto-1.4.15/src/ -I/mnt/c/Users/avkar/cleversky/mosquitto/mosquitto-1.4.15/lib/ -fPIC -Wall -Werror -DBE_JWT -I/src -DDEBUG=1 -I/include -c -o pbkdf2-check.o pbkdf2-check.c
cc -I/mnt/c/Users/avkar/cleversky/mosquitto/mosquitto-1.4.15/src/ -I/mnt/c/Users/avkar/cleversky/mosquitto/mosquitto-1.4.15/lib/ -fPIC -Wall -Werror -DBE_JWT -I/src -DDEBUG=1 -I/include -c -o log.o log.c
cc -I/mnt/c/Users/avkar/cleversky/mosquitto/mosquitto-1.4.15/src/ -I/mnt/c/Users/avkar/cleversky/mosquitto/mosquitto-1.4.15/lib/ -fPIC -Wall -Werror -DBE_JWT -I/src -DDEBUG=1 -I/include -c -o envs.o envs.c
cc -I/mnt/c/Users/avkar/cleversky/mosquitto/mosquitto-1.4.15/src/ -I/mnt/c/Users/avkar/cleversky/mosquitto/mosquitto-1.4.15/lib/ -fPIC -Wall -Werror -DBE_JWT -I/src -DDEBUG=1 -I/include -c -o hash.o hash.c
cc -I/mnt/c/Users/avkar/cleversky/mosquitto/mosquitto-1.4.15/src/ -I/mnt/c/Users/avkar/cleversky/mosquitto/mosquitto-1.4.15/lib/ -fPIC -Wall -Werror -DBE_JWT -I/src -DDEBUG=1 -I/include -c -o be-psk.o be-psk.c
cc -I/mnt/c/Users/avkar/cleversky/mosquitto/mosquitto-1.4.15/src/ -I/mnt/c/Users/avkar/cleversky/mosquitto/mosquitto-1.4.15/lib/ -fPIC -Wall -Werror -DBE_JWT -I/src -DDEBUG=1 -I/include -c -o backends.o backends.c
cc -I/mnt/c/Users/avkar/cleversky/mosquitto/mosquitto-1.4.15/src/ -I/mnt/c/Users/avkar/cleversky/mosquitto/mosquitto-1.4.15/lib/ -fPIC -Wall -Werror -DBE_JWT -I/src -DDEBUG=1 -I/include -c -o cache.o cache.c
cc -I/mnt/c/Users/avkar/cleversky/mosquitto/mosquitto-1.4.15/src/ -I/mnt/c/Users/avkar/cleversky/mosquitto/mosquitto-1.4.15/lib/ -fPIC -Wall -Werror -DBE_JWT -I/src -DDEBUG=1 -I/include -c -o be-jwt.o be-jwt.c
cc -I/mnt/c/Users/avkar/cleversky/mosquitto/mosquitto-1.4.15/src/ -I/mnt/c/Users/avkar/cleversky/mosquitto/mosquitto-1.4.15/lib/ -fPIC -Wall -Werror -DBE_JWT -I/src -DDEBUG=1 -I/include -L/mnt/c/Users/avkar/cleversky/mosquitto/mosquitto-1.4.15/lib/ -fPIC -shared -o auth-plug.so auth-plug.o base64.o pbkdf2-check.o log.o envs.o hash.o be-psk.o backends.o cache.o be-jwt.o -lcurl -L/lib -lcrypto -lmosquitto
/usr/bin/ld: cannot find -lmosquitto
collect2: error: ld returned 1 exit status
Makefile:160: recipe for target 'auth-plug.so' failed
make: *** [auth-plug.so] Error 1
有些 -lmosquitto
未找到。
我假设这是一个图书馆,但所有的图书馆都存在:
$ ls ../mosquitto-1.4.15/lib/
CMakeLists.txt logging_mosq.c memory_mosq.h mosquitto.h net_mosq.h read_handle_shared.c socks_mosq.c time_mosq.c util_mosq.c
cpp logging_mosq.h messages_mosq.c mosquitto_internal.h read_handle.c send_client_mosq.c socks_mosq.h time_mosq.h util_mosq.h
dummypthread.h Makefile messages_mosq.h mqtt3_protocol.h read_handle_client.c send_mosq.c srv_mosq.c tls_mosq.c will_mosq.c
linker.version memory_mosq.c mosquitto.c net_mosq.c read_handle.h send_mosq.h thread_mosq.c tls_mosq.h will_mosq.h
什么是 -lmosquitto
以及如何修复我的构建?
如评论中所述,
在尝试构建插件之前,您需要构建并安装 mosquitto(或安装预构建版本及其开发包)。
错误是因为ld找不到libmosquitto link反对