[英]OpenSSL not found on MacOS Sierra
I am trying to install a PHP MongoDB driver but the installation is failing because it cannot locate the OpenSSL.我正在尝试安装 PHP MongoDB 驱动程序,但安装失败,因为它找不到 OpenSSL。
/Users/username/mongo-php-driver/src/libmongoc/src/mongoc/mongoc-crypto-openssl.c:24:10: fatal error: 'openssl/sha.h' file not found
#include <openssl/sha.h>
^
1 error generated.
make: *** [src/libmongoc/src/mongoc/mongoc-crypto-openssl.lo] Error 1
I read that this has something to do with the latest version of MacOS?我读到这与最新版本的 MacOS 有关? Is there a way to do it, as I really need to install this driver.
有没有办法做到这一点,因为我真的需要安装这个驱动程序。
This is the only solution that worked for me.这是唯一对我有用的解决方案。
cd /usr/local/include
ln -s ../opt/openssl/include/openssl .
Source: https://www.anintegratedworld.com/mac-osx-fatal-error-opensslsha-h-file-not-found/来源: https : //www.anintegratedworld.com/mac-osx-fatal-error-opensslsha-h-file-not-found/
You'll need to install OpenSSL using homebrew , and tell homebrew to create necessary symlinks:您需要使用homebrew安装 OpenSSL,并告诉 homebrew 创建必要的符号链接:
brew install openssl
brew link openssl --force
If you don't already have homebrew installed, you can get it by running this:如果您还没有安装自制软件,您可以通过运行以下命令来获取它:
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
And before all that, if you haven't already installed XCode and the XCode command-line tools:在此之前,如果您还没有安装 XCode 和 XCode 命令行工具:
xcode-select --install
First install libressl
using brew:首先使用 brew 安装
libressl
:
brew install libressl
Then run the following:然后运行以下命令:
export LDFLAGS="-L/usr/local/opt/openssl/lib -L/usr/local/lib \
-L/usr/local/opt/expat/lib" && export CFLAGS="-I/usr/local/opt/openssl/include/ \
-I/usr/local/include -I/usr/local/opt/expat/include" && export \
CPPFLAGS="-I/usr/local/opt/openssl/include/ -I/usr/local/include \
-I/usr/local/opt/expat/include"
You can use environment variable C_INCLUDE_PATH
to tell the compiler to include the path to openssl header files.您可以使用环境变量
C_INCLUDE_PATH
告诉编译器包含 openssl 头文件的路径。
For example, if you just want to do it once:例如,如果你只想做一次:
sudo C_INCLUDE_PATH=/usr/local/opt/openssl/include pecl install mongo
Reference: charles.lescampeurs.org参考: charles.lescampeurs.org
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.