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

相关推荐
BUG_MeDe4 天前
openssl 生成自签名证书步骤
服务器·https·ssl·数字证书
运维行者_4 天前
网站出现 525 错误(SSL 握手失败)修复指南
服务器·网络·数据库·redis·网络协议·bootstrap·ssl
r***99826 天前
使用 Certbot 为 Nginx 自动配置 SSL 证书
运维·nginx·ssl
普普通通的南瓜6 天前
什么是SSL证书?SSL有什么作用?
网络·网络协议·ssl
bitbrowser6 天前
哪些指纹浏览器支持模拟SSL指纹
网络·python·网络协议·ssl
谢尔登6 天前
HTTPS 究竟比 HTTP 好在哪?
http·https·ssl
YannSea8 天前
快速签发SSL证书:acme.sh全指南
网络·网络协议·ssl
kyle~9 天前
计算机网络---传输层安全 SSL与TLS
计算机网络·安全·ssl
站长朋友11 天前
解决SSL证书安装后网站仍显示“不安全”的问题
网络协议·安全·ssl·ssl证书安装不安全·锐安信ssltrus·ocsp响应速度·根证书链完整
挠到秃头的涛某11 天前
华为防火墙web配置SSL-在外人员访问内网资源
运维·网络·网络协议·tcp/ip·华为·ssl·防火墙