未定义的符号 _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 上。有什么建议吗?

我的配置:

谢谢,新年快乐:)

链接器是否正在获取系统上已安装的 sslcrypto 库文件的另一个版本?尝试将 -L 开关添加到 homebrew-installed 文件的路径。