交叉编译百度开放云的MQTT-c时遇到的问题总结

本文详细记录了在交叉编译MQTT-c时遇到的libssl和libcrypto依赖缺失问题,通过添加-lssl和-lcrypto链接选项成功解决了编译错误。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

 

MQTT-c 依赖photo库 
photo库依赖libssl和libcrypto两个库,这两个库包在openssl中 
OpenSSL 是一个强大的安全套接字层密码库,囊括主要的密码算法、常用的密钥和证书封装管理功能及SSL协议,并提供丰富的应用程序供测试或其它目的使用。

昨天编译MQTT-c 出现错误:

arm-linux-gcc -c src/PublisherSync.c -I/home/whl/output/arm-linux/include 
arm-linux-gcc -o PublisherSync ConnectorSync.o PublisherSync.o -L/home/whl/output/arm-linux/lib -lpaho-mqtt3cs -I/home/whl/output/arm-linux/include -lrt 
/usr/local/arm/4.2.2-eabi/usr/bin-ccache/../lib/gcc/arm-unknown-linux-gnueabi/4.2.2/../../../../arm-unknown-linux-gnueabi/bin/ld: warning: libssl.so.1.0.0, needed by /home/whl/output/arm-linux/lib/libpaho-mqtt3cs.so, not found (try using -rpath or -rpath-link) 
/usr/local/arm/4.2.2-eabi/usr/bin-ccache/../lib/gcc/arm-unknown-linux-gnueabi/4.2.2/../../../../arm-unknown-linux-gnueabi/bin/ld: warning: libcrypto.so.1.0.0, needed by /home/whl/output/arm-linux/lib/libpaho-mqtt3cs.so, not found (try using -rpath or -rpath-link) 
/home/whl/output/arm-linux/lib/libpaho-mqtt3cs.so: undefined reference to SSL_connect' 
/home/whl/output/arm-linux/lib/libpaho-mqtt3cs.so: undefined reference to
ERR_print_errors_fp’ 
/home/whl/output/arm-linux/lib/libpaho-mqtt3cs.so: undefined reference to SSL_get1_session' 
/home/whl/output/arm-linux/lib/libpaho-mqtt3cs.so: undefined reference to
CRYPTO_set_locking_callback’ 
/home/whl/output/arm-linux/lib/libpaho-mqtt3cs.so: undefined reference to SSL_set_session' 
/home/whl/output/arm-linux/lib/libpaho-mqtt3cs.so: undefined reference to
OPENSSL_add_all_algorithms_noconf’ 
/home/whl/output/arm-linux/lib/libpaho-mqtt3cs.so: undefined reference to SSL_CTX_set_verify' 
/home/whl/output/arm-linux/lib/libpaho-mqtt3cs.so: undefined reference to
SSL_load_error_strings’ 
/home/whl/output/arm-linux/lib/libpaho-mqtt3cs.so: undefined reference to SSL_get_cipher_list' 
/home/whl/output/arm-linux/lib/libpaho-mqtt3cs.so: undefined reference to
SSLeay_version’ 
/home/whl/output/arm-linux/lib/libpaho-mqtt3cs.so: undefined reference to SSL_CTX_use_certificate_chain_file' 
/home/whl/output/arm-linux/lib/libpaho-mqtt3cs.so: undefined reference to
SSL_free’ 
/home/whl/output/arm-linux/lib/libpaho-mqtt3cs.so: undefined reference to SSL_CTX_set_default_passwd_cb_userdata' 
/home/whl/output/arm-linux/lib/libpaho-mqtt3cs.so: undefined reference to
SSL_CTX_new’ 
/home/whl/output/arm-linux/lib/libpaho-mqtt3cs.so: undefined reference to SSL_get_verify_result' 
/home/whl/output/arm-linux/lib/libpaho-mqtt3cs.so: undefined reference to
SSL_read’ 
/home/whl/output/arm-linux/lib/libpaho-mqtt3cs.so: undefined reference to SSL_set_fd' 
/home/whl/output/arm-linux/lib/libpaho-mqtt3cs.so: undefined reference to
SSL_pending’

这个错误很奇怪,排查了好久,因为同样的Makefile文件,交叉编译 时就报错,编译 x86版本时就很正常。 
后来google到要在编译时加上 -lssl -lcrypto,就可以顺利编译通过了。

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值