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

相关推荐
宋拾壹9 小时前
物理服务器映射端口
网络协议·ssl
张3蜂13 小时前
SQL Server 数据库 的通信加密配置SSL安全连接
数据库·安全·ssl
普普通通的南瓜2 天前
无需域名,直通安全:一年期免费IP SSL证书
网络·网络协议·tcp/ip·安全·ssl
2301_810746313 天前
CKA冲刺40天笔记 - day20-day21 SSL/TLS详解
运维·笔记·网络协议·kubernetes·ssl
量子物理学4 天前
openssl自建CA并生成自签名SSL证书
网络·网络协议·ssl
成空的梦想4 天前
除了加密,它还能验明正身:SSL如何防范网络钓鱼?
网络·https·ssl
亲爱的非洲野猪5 天前
为Tomcat部署SSL证书:从零到一的HTTPS配置指南
https·tomcat·ssl
丁丁丁梦涛5 天前
EMQX配置 ssl 和 wss
网络·网络协议·ssl·emqx·wss
Wokoo75 天前
HTTP不同版本核心对比
网络·网络协议·tcp/ip·http·udp·ssl
GDAL5 天前
客户端与服务器SSL协议/加密套件不兼容:完整解决方案
服务器·ssl