This has changed with the latest verison of brew on Big Sur (11.5.1) on a Macbook M1 (just for completeness):
export LDFLAGS="-L/opt/homebrew/opt/openssl@3/lib"
export CPPFLAGS="-I/opt/homebrew/opt/openssl@3/include"
Answer from MuseumPiece on Stack OverflowThis has changed with the latest verison of brew on Big Sur (11.5.1) on a Macbook M1 (just for completeness):
export LDFLAGS="-L/opt/homebrew/opt/openssl@3/lib"
export CPPFLAGS="-I/opt/homebrew/opt/openssl@3/include"
this command solve my problem:
brew install [email protected]
cp /usr/local/opt/[email protected]/lib/pkgconfig/*.pc /usr/local/lib/pkgconfig/
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
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.
If brew link openssl --force gives you this message:
Warning: Refusing to link: openssl Linking keg-only openssl means you may end up linking against the insecure, deprecated system OpenSSL while using the headers from Homebrew's openssl. Instead, pass the full include/library paths to your compiler e.g.: -I/usr/local/opt/openssl/include -L/usr/local/opt/openssl/lib
Try this:
$ brew doctor (now fix anything that it tells you to fix)
$ brew update
$ brew upgrade
Now let's install it:
$ brew install openssl
And now we'll link it into our public area so you don't have to figure out the magic environment variable to set while building your favorite OpenSSL-backed library:
$ cd /usr/local/include
$ ln -s ../opt/openssl/include/openssl .
All done! Enjoy
If you are on Mac OS X El Capitan, Apple doesn't include openssl any more because of security problems openssl had, I have similar problem installing Passenger. brew just installs openssl itself without development headers.
If you are on an older version of Mac OS X than El Capitan, you can use:
xcode-select --install
which installs openssl development headers as well.
EDIT:
Updating brew and installing openssl and force linking openssl to brew version solved my problem:
$ brew update
$ which openssl
/usr/bin/openssl
$ brew install openssl
$ brew link openssl --force
$ which openssl
/usr/local/bin/openssl
Since OpenSSL 1.0.2 is end of lifed by the end of 2019, it is no longer available via Homebrew. This is mentioned in the Homebrew 2.2.0 announcement.
It is fairly straightforward to build and install OpenSSL 1.0.2 yourself from source. You can download your required version from the Old 1.0.2 Releases page and follow the instructions found in INSTALL.
It may be possible as well to recover an older formula and install from that, but I can not guarantee how well that works. The following steps did complete the installation process:
$ git clone https://github.com/Homebrew/homebrew-core.git
$ cd homebrew-core
$ git checkout 75b57384 Formula/openssl.rb
$ brew install Formula/openssl.rb
For me, this showed:
Warning: openssl 1.1.1d is available and more recent than version 1.0.2m.
==> Downloading https://homebrew.bintray.com/bottles/openssl-1.0.2m.high_sierra.bottle.tar.gz
and went on happily after that. A quick try at the end gives some confidence that it worked out well:
$ /usr/local/opt/openssl/bin/openssl version
OpenSSL 1.0.2m 2 Nov 2017
If you prefer not to use git directly, you can also try downloading that version of openssl.rb from gitHub.com and run brew install on it.
If you wonder where that commit hash came from, I happened to know that the formula used to be called -- surprise -- openssl.rb (but using git to query for removed files would have worked as well). Therefore, I inspected the history for Formula/openssl.rb and found:
$ git log -- Formula/openssl.rb
...
commit 75b573845a17aaf3f7c84dc58e97cf5fe39a502b
Author: BrewTestBot <[email protected]>
Date: Thu Nov 2 17:20:33 2017 +0000
openssl: update 1.0.2m bottle.
Recently I was struggling due to the recent update in openssl version from 1.0 to 1.1 and wanted to revert it back to older version. No other solution except the one given below worked for me:
brew install rbenv/tap/[email protected]
rvm reinstall 1.9.3-p551 --with-openssl-dir='/usr/local/opt/[email protected]'
gem update --system
IMO the best way to install openssl on MacOS is to use Homebrew. This will not only install openssl, but will also allow it to be upgraded in the future.
brew install openssl
If you want to make the Homebrew version the default (rather than the LibreSSL that comes with MacOS), you will also need put the Hombrew-installed openssl on your path ahead of the MacOS version. While it is possible to accomplish this by putting /opt/homebrew/bin on your PATH ahead of /usr/bin, I strongly discourage this, because it makes you vulnerable to unintentionally installing a malicious Homebrew package named something like ls that overrides your default ls with malicious code. Instead, my personal preference is to have a user-level directory where I maintain a small set of binaries that override the defaults.
# Create a user-level bin directory, if it doesn't already exist.
mkdir -p ~/bin
# Create a symlink to the Homebrew openssl, if such a symlink does not already exist
ln -fs /opt/homebrew/bin/openssl ~/bin/openssl
Then, put ~/bin on your PATH, ahead of /usr/bin. This part depends on which shell you are using. For bash, you can add this to your ~/.bash_profile.
# User-level binaries, manually added
PATH="${HOME}/bin:${PATH}"
The first option is the simplest one: do nothing. macOS has shipped with OpenSSL preinstalled since 2000.
You can download a binary distribution of OpenSSL. The OpenSSL project does not itself publish binary releases, but they maintain a list of third-party resources that publish OpenSSL binaries.
You can install it using MacPorts.
You can install it using Homebrew.
You can compile it yourself. You already downloaded the source code, so all you need is to follow the instructions in the INSTALL.md file you are showing in your screenshot. I assume that, since you chose to use an inofficial development version, you may run into some bugs.
If you're using Homebrew /usr/local/bin should already be at the front of $PATH or at least come before /usr/bin. If you now run brew link --force openssl in your terminal window, open a new one and run which openssl in it. It should now show openssl under /usr/local/bin.
installed openssl on mac with brew but nothing found on /usr/local/bin where other brew installed bins are located. Found my fresh openssl here:
/usr/local/opt/openssl/bin/openssl
Run it like this:
/usr/local/opt/openssl/bin/openssl version
I don't want to update OS X openssl, while some OS stuff or other 3rd party apps may have dependency on older version.
I also don't mind longer path than just openssl
Writing this here for all the Googlers who are looking for location of openssl installed by brew.