【问题标题】:Undefined symbols _EVP_PKEY_CTX_new_id [duplicate]未定义的符号_EVP_PKEY_CTX_new_id [重复]
【发布时间】:2015-12-31 17:17:34
【问题描述】:

我有这个不能在 OS X 上编译的 C++ 代码:

#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;
}

在链接我得到这个错误:

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 doc,说它应该被定义: https://www.openssl.org/docs/manmaster/crypto/EVP_PKEY_CTX_new.html

此代码在 Linux(Debian 7 with OpenSSL 1.0.1e)上完美运行。但不是在 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 安装)

感谢新年快乐:)

【问题讨论】:

标签: c++ macos openssl clang


【解决方案1】:

链接器是否可能拾取系统上已安装的另一个版本的sslcrypto 库文件?尝试添加 -L 开关和 homebrew 安装文件的路径。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2017-05-28
    • 2011-09-30
    • 2012-10-07
    • 1970-01-01
    • 1970-01-01
    • 2017-03-08
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多