我正在尝试将 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/