編譯 libevent(源檔案在/Users/carl/Downloads/libevent-2.1.8-stable),執行make命令是,報
Install libevent bufferevent_openssl.c:60:10: fatal error: 'openssl/bio.h' file
第一反應,感覺是不是 openssl版本太低了。
1. 查看openssl版本,發現版本比較低
$ openssl versionOpenSSL 0.9.8zh 14 Jan 2016
2. 升級spenssl,執行
brew install openssl
輸出(前面的輸出忽略)如下:
==> Downloading https://homebrew.bintray.com/bottles/openssl-1.0.2l.sierra.bottle.tar.gz
######################################################################## 100.0%
==> Pouring openssl-1.0.2l.sierra.bottle.tar.gz
==> Caveats
A CA file has been bootstrapped using certificates from the SystemRoots
keychain. To add additional certificates (e.g. the certificates added in
the System keychain), place .pem files in
/usr/local/etc/openssl/certs
and run
/usr/local/opt/openssl/bin/c_rehash
This formula is keg-only, which means it was not symlinked into /usr/local,
because Apple has deprecated use of OpenSSL in favor of its own TLS and crypto libraries.
If you need to have this software first in your PATH run:
echo 'export PATH="/usr/local/opt/openssl/bin:$PATH"' >> ~/.zshrc
For compilers to find this software you may need to set:
LDFLAGS: -L/usr/local/opt/openssl/lib
CPPFLAGS: -I/usr/local/opt/openssl/include
==> Summary
� /usr/local/Cellar/openssl/1.0.2l: 1,709 files, 12.2MB
輸出以上資訊,說明安裝成功,安裝目錄在(/usr/local/Cellar/openssl/1.0.2l)
3. 配置openssl環境變數,指向新安裝的openssl
a. 執行 whereis openssl
輸出 /usr/bin/openssl
b. 備份原openssl,執行 mv /usr/bin/openssl /usr/bin/openssl_old
c. 建立openssl命令軟串連,執行 ln -s /usr/local/Cellar/openssl/1.0.2l/bin/openssl /usr/bin/openssl
d.再執行 openssl version
輸出 OpenSSL 1.0.2l 25 May 2017
說明升級成功。
openssl升級成功後,重新編譯libevent,執行make名了,還是報Install libevent bufferevent_openssl.c:60:10: fatal error: 'openssl/bio.h' file錯誤,
於是把新安裝的openssl目錄的下的標頭檔 拷貝到libevent源檔案目錄下,
執行 cp -R /usr/local/Cellar/openssl/1.0.2l/bin/openssl/include /Users/carl/Downloads/libevent-2.1.8-stable
重新make,編譯成功。
參考資料 :
http://blog.csdn.net/hackcoder/article/details/52442350
http://blog.csdn.net/pz0605/article/details/51954868