ignite-me
ignite-me

Reputation: 778

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.

/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? Is there a way to do it, as I really need to install this driver.

Upvotes: 12

Views: 28186

Answers (4)

sideshowbarker
sideshowbarker

Reputation: 88306

You’ll need to install OpenSSL using homebrew, and tell homebrew to create symlinks:

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-select --install

Upvotes: 10

Farshid Ashouri
Farshid Ashouri

Reputation: 17719

First install libressl using brew:

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"

Upvotes: 4

Myles
Myles

Reputation: 484

You can use environment variable C_INCLUDE_PATH to tell the compiler to include the path to openssl header files.

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

Upvotes: 1

5ive
5ive

Reputation: 273

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/

Upvotes: 20

Related Questions