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

相关推荐
网安INF1 小时前
SSL/TLS密钥派生机制与安全攻防体系深度解析
网络·安全·网络安全·密码学·ssl
网安INF11 小时前
SSL/TLS协议深度解析:记录、警报与握手
网络·网络协议·安全·网络安全·密码学·ssl
蜜獾云1 天前
charles抓包原理
服务器·https·ssl
程序猿编码1 天前
轻量高效的HTTP/HTTPS代理:SSL拦截与流量管控核心解析
http·https·ssl·代理
bkspiderx1 天前
解密网络安全基石:SSL、TLS与HTTPS的前世今生
web安全·https·ssl·tls
网安INF1 天前
SSL/TLS体系结构
网络·网络协议·网络安全·ssl
全栈工程师修炼指南2 天前
Nginx | HTTPS 加密传输:Nginx 反向代理与上游服务 SSL 双向认证实践
网络·数据库·nginx·https·ssl
爬山算法3 天前
Netty(21)Netty的SSL/TLS支持是如何实现的?
网络·网络协议·ssl
青木川崎4 天前
Mac使用idea连接svn报错svn: E230001: Server SSL certificate verification failed
svn·intellij-idea·ssl
全栈工程师修炼指南4 天前
Nginx | HTTPS 加密传输:客户端与Nginx服务端 SSL 双向认证实践
运维·网络·nginx·https·ssl