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

相关推荐
PinTrust SSL证书1 天前
Sectigo(Comodo)域名型DV通配符SSL
网络·网络协议·http·网络安全·https·软件工程·ssl
PinTrust SSL证书2 天前
Sectigo(Comodo)企业型OV通配符SSL
网络·网络协议·网络安全·小程序·https·ssl
中科三方3 天前
SSL证书、域名与IP地址:三者关系全面解析与常见误区澄清
网络·tcp/ip·ssl
PinTrust SSL证书4 天前
IP地址访问网站,怎么去除不安全提示?
网络协议·tcp/ip·安全·网络安全·https·ssl
PinTrust SSL证书6 天前
Geotrust企业型OV通配符SSL
网络协议·网络安全·小程序·https·云计算·ssl
墨香幽梦客6 天前
全站HTTPS化实战:SSL证书管理、自动续期与TLS 1.3性能优化详解
性能优化·https·ssl
yleihj10 天前
vCenter计算机SSL证书续期
服务器·网络协议·ssl
BullSmall13 天前
Prometheus 如何配置监控 SSL 证书即将过期
网络协议·ssl·prometheus
Zhu75813 天前
【软件更新】在Ubuntu24 LTS中更新openssl到指定版本,例如openssl3.5.6 LTS
linux·ssh·ssl
阿凤2116 天前
nginx部署如何配置ssl证书
运维·nginx·ssl