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

相关推荐
木子欢儿1 天前
Prometheus Blackbox域名SSL证书监控并设置AlertManager告警
网络·网络协议·ssl·prometheus
草根站起来1 天前
ip版SSL证书
服务器·tcp/ip·ssl
草根站起来1 天前
SSL证书根证书没有二级根证书、三级根证书、四级根证书,SSL证书参数诈骗被迫使用了套牌贴牌非原厂SSL和证书
网络·网络协议·ssl
青春不流名1 天前
如何在Kafka中使用SSL/TLS证书认证
分布式·kafka·ssl
kaka_19941 天前
如何解决驱动程序无法通过使用安全套接字层(SSL)加密与 SQL Server 建立安全连接。
linux·安全·ssl
白驹过隙^^2 天前
OB-USP-AGENT安装使用方法
数据库·经验分享·网络协议·tcp/ip·github·ssl
Arwen3036 天前
等保2.0三级认证内网IP SM2 SSL证书
网络协议·tcp/ip·ssl
Arwen3036 天前
内网IP证书:安全加密全指南
网络·网络协议·tcp/ip·ssl
Arwen3036 天前
国密SSL内网IP部署全攻略
网络·网络协议·tcp/ip·ssl
shcoc7 天前
备用 申请acme 申请ssl
网络·网络协议·ssl