未定义的符号 _EVP_PKEY_CTX_new_id
Undefined symbols _EVP_PKEY_CTX_new_id
我的 C++ 代码无法在 OS X:
上编译
#include <iostream>
#include <openssl/evp.h>
int main(int argc,char *argv[]){
EVP_PKEY_CTX *pctx;
pctx = EVP_PKEY_CTX_new_id(EVP_PKEY_EC, NULL);
return 0;
}
在 link 我得到这个错误:
Undefined symbols for architecture x86_64:
"_EVP_PKEY_CTX_new_id", referenced from:
_main in test-a22ea1.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
编译为:
g++ test.cpp -o test -lssl -lcrypto
OpenSSl 文档,说应该定义它:
https://www.openssl.org/docs/manmaster/crypto/EVP_PKEY_CTX_new.html
此代码在 Linux(带有 OpenSSL 1.0.1e 的 Debian 7)上完美运行。但不在 OS X 上。有什么建议吗?
我的配置:
- OS X: 10.11.2
- clang:Apple LLVM 版本 7.0.2 (clang-700.1.81)
- openSSL:OpenSSL 1.0.2e 2015 年 12 月 3 日(与 Homebrew 一起安装)
谢谢,新年快乐:)
链接器是否正在获取系统上已安装的 ssl
和 crypto
库文件的另一个版本?尝试将 -L 开关添加到 homebrew-installed 文件的路径。
我的 C++ 代码无法在 OS X:
上编译#include <iostream>
#include <openssl/evp.h>
int main(int argc,char *argv[]){
EVP_PKEY_CTX *pctx;
pctx = EVP_PKEY_CTX_new_id(EVP_PKEY_EC, NULL);
return 0;
}
在 link 我得到这个错误:
Undefined symbols for architecture x86_64:
"_EVP_PKEY_CTX_new_id", referenced from:
_main in test-a22ea1.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
编译为:
g++ test.cpp -o test -lssl -lcrypto
OpenSSl 文档,说应该定义它: https://www.openssl.org/docs/manmaster/crypto/EVP_PKEY_CTX_new.html
此代码在 Linux(带有 OpenSSL 1.0.1e 的 Debian 7)上完美运行。但不在 OS X 上。有什么建议吗?
我的配置:
- OS X: 10.11.2
- clang:Apple LLVM 版本 7.0.2 (clang-700.1.81)
- openSSL:OpenSSL 1.0.2e 2015 年 12 月 3 日(与 Homebrew 一起安装)
谢谢,新年快乐:)
链接器是否正在获取系统上已安装的 ssl
和 crypto
库文件的另一个版本?尝试将 -L 开关添加到 homebrew-installed 文件的路径。