25

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?

1
26

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
3
  • 1
    How do you do it without brew and without sudo? Mar 24 '17 at 22:40
  • 4
    openssl is not the same as libssl-dev. The first one is for direct use, the second is for linking. UPD: ok, for mac they are bundled in one package, but you need to run export LDFLAGS="-L/usr/local/opt/openssl/lib" export CPPFLAGS="-I/usr/local/opt/openssl/include"
    – Imaskar
    Mar 12 '19 at 17:14
  • @tommy.carstensen, you can download openssl and compile it from source on the mac and install it to a custom path or folder. I needed it for the "links" browser. Jan 22 at 22:59
12

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.

1
4

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 openssl@1.1 you may need to set:
  export LDFLAGS="-L/usr/local/opt/openssl@1.1/lib"
  export CPPFLAGS="-I/usr/local/opt/openssl@1.1/include"

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

3
  • On MacOS /usr/local/opt/openssl already points to ../Cellar/openssl@1.1/1.1.1i, could it be a case that pip install psycopg2 doesn't follow symlinks? Doesn't seem reasonable! Feb 11 at 16:23
  • In addition to my previous comment, I already have env | grep FLAGS ==> LDFLAGS=-L/usr/local/opt/libpq/lib CPPFLAGS=-I/usr/local/opt/libpq/include Feb 11 at 16:24
  • Here's the solution (I was getting an error about libssl) stackoverflow.com/a/61159643/1459079 Feb 11 at 16:29
0

For Macports, install sudo port install openssl and set your environment variables as below.

export LDFLAGS="-L/opt/local/lib"
export CPPFLAGS="-I/opt/local/include/openssl"

I found out about these locations via the command port contents openssl | grep -v "man"

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.