undefined reference to `dlopen‘ ‘SSL_library_init‘ `X509_certificate_type‘

使用Crow的时候需要注意crow依赖asio依赖OpenSSL,asio要求1.22以上版本,我使用的是1.26.0;

这个版本的asio要求OpenSSL是1.0.2,其他版本我得机器上编不过,ubuntu上默认带的OpenSSL是1.1.1;

所以我下载了OPENSSL1.2.0重装,地址: https://www.openssl.org/source/old/

编译cpp启用Crow的SSL时会出现一些问题:

比如:

  • 1 undefined reference to `SSL_library_init'

出现这个提示需要在编译时指定链接 crypto 和 ssl 库

  • 2 undefined reference to `dlopen'

出现这个提示需要在编译时指定链接 dl 库

  • 3 undefined reference to `X509_certificate_type'

出现这个提示需要在编译时指定链接openssl的位置;

  • 4 以上需要指定的库和地址都加上之后还是报错,可能是指令顺序问题;
    例如

    // ×
    g++ example_ssl.cpp -L/usr/local/openssl/lib -lssl -ldl -lcrypto -DCROW_ENABLE_SSL=1 -o ssl_example -std=c++11 -lpthread

    // √
    g++ example_ssl.cpp -L/usr/local/openssl/lib -lssl -lcrypto -DCROW_ENABLE_SSL=1 -o ssl_example -std=c++11 -lpthread -ldl

上面两行只是调整了 -ldl 所在的位置,就会消除部分错误,

具体原因参考

https://qastack.cn/programming/956640/linux-c-error-undefined-reference-to-dlopen

https://stackoverflow.com/questions/11893996/why-does-the-order-of-l-option-in-gcc-matter/11894098#11894098

相关推荐
今夕资源网19 小时前
本地SSL证书生成工具本地 HTTPS 配置不用再敲命令:CertTool 一站式管理自签证书与 Hosts
网络协议·https·ssl·ssl证书生成·ssl本地测试证书
瓦格哈儿3 天前
删掉旧 SSL 证书会影响线上业务吗?风险点梳理
网络协议·https·ssl
姚不倒3 天前
HAProxy 系列(二):健康检查与 SSL 卸载 — 保障可用性与性能
运维·网络·网络协议·ssl·haproxy
MyFreeIT5 天前
Let‘s Encrypt SSL 製作免費證書
网络协议·https·ssl
00后程序员张5 天前
Android证书绑定抓包失败?Android SSL Pinning绕过实战指南
android·网络协议·计算机网络·网络安全·adb·https·ssl
武帝为此5 天前
【TLS SSL 介绍】
网络·网络协议·ssl
吠品8 天前
SQL Server 版本查询的几种实用方法
数据库·网络协议·ssl
瓦格哈儿9 天前
内网环境也需要证书?聊聊内网 IP 证书的适用边界
网络协议·ssl
CZIDC10 天前
华为服务器TS200-2280 V2 iBMC导入SSL证书后问题案例分析
服务器·https·ssl
m0_6174939412 天前
SSLError [ASN1: NOT_ENOUGH_DATA] 问题排查与解决指南
python·ssl