c++ - 链接 ssl 库

标签 c++ ssl compiler-errors compilation

我正在尝试将 ssl 库链接到我的编译命令。我通过安装它

sudo apt-get install libssl-dev

任何我的编译命令

g++ -Wall -pedantic -std=c++11 -lcrypto -lssl file.cpp

然而它提示:

:(.text+0x19b): undefined reference to `SSL_library_init'
:(.text+0x1a0): undefined reference to `SSLv23_client_method'
:(.text+0x1a8): undefined reference to `SSL_CTX_new'
:(.text+0x1ff): undefined reference to `SSL_CTX_ctrl'
:(.text+0x20e): undefined reference to `SSL_new'
:(.text+0x26b): undefined reference to `SSL_set_fd'
:(.text+0x2b6): undefined reference to `SSL_get_peer_certificate'
:(.text+0x399): undefined reference to `PEM_write_X509'
:(.text+0x41d): undefined reference to `SSL_write'
(.text+0x511): undefined reference to `SSL_read'

所有来源都表明我的链接是正确的。我在使用加密库时遇到了同样的问题,但使用安装命令修复了它(好像我没有它)

我正在运行 Ubuntu。

最佳答案

注意 ssl 应该放在 crypto 之前。 您也可以尝试将“/usr/local/ssl/lib”添加到链接器搜索路径:

g++ -Wall -pedantic -std=c++11 -lssl -lcrypto file.cpp -L/usr/local/ssl/lib

关于c++ - 链接 ssl 库,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43835759/

相关文章:

c++ - 在OpenCV中访问灰度图像的像素值

c++ - 我尝试在 linuxLite 上使用 qt creator 运行 qt-vtk-project

ssl - boost::asio 无法仅接受 TLS 1.2?

node.js - 无法从 NodeJS 程序建立到 MongoDB 的 SSL 连接

c# - 由于多个依赖项中的相同属性类型导致编译错误

android - 我应该如何为Android平台编译tesseract-4?

jsp - 无法编译单个jsp

c++ - 如何处理 csv 文件输入流,我需要将文件每一行中的数据划分为 6 个不同的变量(字符串和 int 类型)

c++ - GCC STL 边界检查

postgresql - Aurora 无服务器 Postgresql 无法通过 TLS/SSL 连接