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

相关推荐
吠品3 天前
一次 Nginx 报错 unexpected end of file 的排查记录
网络协议·https·ssl
Orchestrator_me3 天前
Python pip install报SSL错误
python·ssl·pip
曦月合一3 天前
在 Linux 服务器上执行这些命令来导入 SSL 证书
linux·服务器·ssl
春风得意之时4 天前
前端安装项目出现代理问题和ssl认证问题
前端·网络协议·ssl
HelloWorld工程师4 天前
网站开启HTTPS:2步解决Chrome“不安全”提示
chrome·网络协议·https·ssl
霸道流氓气质4 天前
SSL Socket 通信与本地 Mock Server 实践指南
网络·网络协议·ssl
上海云盾-小余8 天前
SSL 证书部署误区避坑:加密部署与防劫持落地教程
网络协议·iphone·ssl
计算机安禾9 天前
【算法分析与设计】第46篇:近似难度与不可近似性理论
网络协议·算法·ssl
小二·9 天前
HTTPS 证书问题排查(SSL/TLS)实战
网络协议·https·ssl
hoho_1210 天前
目标主机使用了不受支持的SSL加密算法【原理扫描】
网络·网络协议·ssl