How to install libssl-dev ,libffi-dev on Mac os?

I can install libssl-dev and libffi-dev on Ubuntu with the command apt-get install libssl-dev libffi-dev, But I can't install on Mac; I have tried using the command: brew install libssl-dev libffi but not working for me.

What do I need to do to get homebrew to install this?


Solution 1:

Those particular packages do not exist under those names on both MacPorts and Homebrew - hence the errors you are receiving. In order to install these particular packages on OS X, you will want to use openssl. The following command should help you out:

brew install openssl

If you already have openssl installed, try running the following in order to repair it - some users over on Stack Overflow reported this as a fix when trying to get Django working.

brew unlink openssl && brew link openssl --force

Solution 2:

I was trying to get Crystal off the ground on MacOS Mojave and ran into a similar issue.

This is the error message I was seeing:

Error: execution of command failed with code: 1: `cc "${@}" -o '/Users/mymbp/.cache/crystal/crystal-run-server.tmp'  -rdynamic  
`command -v pkg-config > /dev/null && pkg-config --libs --silence-errors libssl || printf %s '-lssl -lcrypto'` `command -v pkg-config > /dev/null && pkg-config --libs
 --silence-errors libcrypto || printf %s '-lcrypto'` -lz -lpcre -lgc -lpthread 
/usr/local/Cellar/crystal/0.27.0/src/ext/libcrystal.a -levent -liconv -ldl -
L/usr/lib -L/usr/local/lib`

Searching /usr/local/lib I noticed there was no mention of libssl.

So I added a symlink and that seemed to fix it.

ln -s /usr/local/Cellar/openssl/1.0.2p/lib/libssl.dylib /usr/local/lib/

Note: The current version of openssl that brew drops is 1.0.2p, your version may be different.

Solution 3:

openssl was already installed, but I could not build psycopg2 because it was complaining about missing -lssl. I've followed the steps from Simon Sheehan but it was still not available.

But looking at the message after force linking openssl:

For compilers to find [email protected] you may need to set:
  export LDFLAGS="-L/usr/local/opt/[email protected]/lib"
  export CPPFLAGS="-I/usr/local/opt/[email protected]/include"

So I did what it says. I've added those two lines in my ~/.bashrc. And psycopg2 builded without errors this time.