Mac OS X安装libevent库报Install libevent bufferevent_openssl.c:60:10: fatal error: 'openssl/bio.h' file

编译 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 version OpenSSL 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

评论

此博客中的热门博文

How to Build a Cocos2d-x Android App for Multiple Architectures

Android跨平台编译 —— libevent

开源 C++ 库列表