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

相关推荐
itachi-uchiha1 天前
命令行以TLS/SSL显式加密方式访问FTP服务器
服务器·网络协议·ssl
moppol1 天前
SSL/TLS握手全流程拆解:从“Hello“到“安全通道“的每一个字节
网络·安全·ssl
itachi-uchiha1 天前
使用vsftpd搭建FTP服务器(TLS/SSL显式加密)
运维·服务器·ssl
Think Spatial 空间思维2 天前
【实施指南】Android客户端HTTPS双向认证实施指南
android·网络协议·https·ssl
'tubug'2 天前
数字证书_CA_详解
https·ssl
锐成19192 天前
FTPS、HTTPS、SMTPS以及WebSockets over TLS的概念及其应用场景
网络协议·https·ssl
斯普信云原生组2 天前
K8S主机漏洞扫描时检测到kube-服务目标SSL证书已过期漏洞的一种永久性修复方法
https·kubernetes·ssl
依稀i1234 天前
MySQL连接报SSL错误
数据库·mysql·ssl
不懂说话的猿5 天前
PostgreSQL数据库配置SSL操作说明书
数据库·postgresql·ssl·认证·postgresql安全加固
zqx_75 天前
随记 配置服务器的ssl整个过程
网络·网络协议·ssl