2017-07-21 243 views
0

我想在我的Mac上使用CLion(CMake)運行openssl。無法在macOS-Sierra上使用openssl

安裝了OpenSSL與自制

brew install openssl 

但還是克利翁是無法找到的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 

然後我用下面的克利翁(的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中刪除了開發頭文件,所以很多指南都不再適用。

+1

另請參見[家釀拒不鏈接的OpenSSL(http://stackoverflow.com/q/38670295),[更新的OpenSSL與自制OS X](HTTP:/ /stackoverflow.com/q/15185661),[如何安裝最新版本的openssl Mac OS X El Capitan](http://stackoverflow.com/q/35129977),[如何在OS X中升級OpenSSL?](http ://apple.stackexchange.com/q/126830),[使用HomeBrew的Openssl安裝失敗](http://superuser.com/q/486389)等 – jww

回答

0

這似乎是與鏈接有關的問題。我使用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