【问题标题】:Can't use openssl on macOS-Sierra无法在 macOS-Sierra 上使用 openssl
【发布时间】:2017-07-21 17:56:43
【问题描述】:

我想在我的 Mac 上使用 CLion (CMake) 运行 openssl。

用自制软件安装 openssl

brew install openssl

但 CLion 仍然无法找到 openssl。过去可以使用

brew link openssl

但今天似乎被自制软件拒绝了。

Warning: Refusing to link: openssl
Linking keg-only openssl means you may end up linking against the insecure, 
deprecated system OpenSSL while using the headers from Homebrew's openssl.
Instead, pass the full include/library paths to your compiler e.g.:
   -I/usr/local/opt/openssl/include -L/usr/local/opt/openssl/lib

然后我在 CLion (CMakeLists.txt) 中使用了以下 cmake 选项

set(I "/usr/local/opt/openssl/include")
set(L "/usr/local/opt/openssl/lib")
include_directories(${I})

但我还是明白了:

Undefined symbols for architecture x86_64:
  "_EVP_DigestSignFinal", referenced from:
Undefined symbols for architecture x86_64:
  "_EVP_DigestSignFinal", referenced from:
      OpenSSL::signMsg(Buffer, Buffer, SignOptions) in libMyLib.a(ssl_state.cpp.o)
      OpenSSL::signMsg(Buffer, Buffer, SignOptions) in libMyLib.a(ssl_state.cpp.o)

我能找到的关于这个主题的几乎所有内容都是关于旧版本的 macOS,但是 Apple 已经从 openssl 0.9.8 中删除了开发头文件,所以很多指南都不再适用了。

【问题讨论】:

标签: macos cmake openssl homebrew macos-sierra


【解决方案1】:

这似乎是链接的问题。我使用的是 Macports 而不是 Homebrew,但也在 MacOS Sierra 上。

由于我看不到您的代码并且您没有提供最低工作示例,因此我使用了:https://github.com/Andersbakken/openssl-examples.git

和你一样,我在CMakeLists.txt中添加了以下几行

set(I "/opt/local/include")
set(L "/opt/local/lib")
include_directories(${I})

它对我来说很好用:

cmake .
make

您是否验证过,在您输入CMakeLists.txt 的路径下确实有必要的文件?

你试过了吗:

brew info openssl

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2017-06-22
    • 1970-01-01
    • 2017-06-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-04-19
    • 2017-04-10
    相关资源
    最近更新 更多