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

相关推荐
赤月奇4 天前
https改为http
数据挖掘·https·ssl
k7Cx7e5 天前
宝塔域名强制SSL和带www的方法
网络·网络协议·ssl
qq_316837755 天前
使用 certbot docker镜像生成阿里云域名ssl证书
阿里云·docker·ssl
文静小土豆5 天前
CentOS 7 升级 OpenSSL 3.5.4 详细指南
linux·运维·centos·ssl
biubiubiu07065 天前
Certbot 申请SSL证书的三种方式详解(Ubuntu 22.04环境)
网络·网络协议·ssl
宇宙核6 天前
FreeSSL实现域名证书免费无限自动续签续期流程
linux·服务器·ssl·持续部署
风早爽太7 天前
使用 CocoaPods 出现 SSL 证书验证失败错误的临时解决方案
ssl·cocoapods
qq_316837758 天前
caddy 使用阿里云的域名通过dns验证申请ssl证书
阿里云·云计算·ssl
无籽西瓜a10 天前
SSL/TLS工作流程以及HTTP与HTTPS详解
http·https·ssl
数据知道14 天前
PostgreSQL:如何配置数据库的传输层加密(SSL加密连接)
数据库·postgresql·ssl