Mac OSX fatal error: ‘openssl/sha.h’ file not found

By | April 19, 2016

If you have come across this sha.h not found error on a Mac, it is because Apple dropped support for openssl.

Apple deprecated its OpenSSL shared libraries a while back (with OS X 10.7). That’s because OpenSSL doesn’t offer release-to-release binary compatibility, so we can’t update the shared libraries to the latest OpenSSL without breaking all the existing clients.

Source: http://lists.apple.com/archives/macnetworkprog/2015/Jun/msg00025.html

How to get around this?

> brew install openssl

This is the easiest and quickest way. This will install a folder called openssl into your /usr/local/Cellar folder (where all your other brew downloads reside).

The trick though is to go into your usr/local/includes folder and create a symlink (aka folder shortcut in the windows world) to your Cellar folder.

cd /usr/local/include 
ln -s ../opt/openssl/include/openssl .

ln is to create a link and -s means it is symbolic. Next we are saying what is the destination and the . (dot) indicates to create the link in the current directory.

Now when you compile the code, the warning should disappear because your compiler will search in this directory (one of many standard directories) and find the header file sha.h via the shortcut link.

You should probably run a few other commands as best practise:

brew doctor 
> brew update 
> brew upgrade

Inspired by: https://solitum.net/openssl-os-x-el-capitan-and-brew/

Category: OSX

One thought on “Mac OSX fatal error: ‘openssl/sha.h’ file not found

Leave a Reply

Your email address will not be published. Required fields are marked *