ld: library not found for -lssl while installing mysql2 gem
Homebrew moved files around, here is what works now 2022-04:
- Macbook Arm M1
- MacOS Monterey 12.3.1
- Homebrew 3.4.7
gem install mysql2 -v '0.5.3' -- \
--with-cflags=\"-I/opt/homebrew/opt/openssl/include\" \
--with-ldflags=\"-L/opt/homebrew/opt/openssl/lib\"
On macOS Big Sur I used the following commands to get the mysql2
gem installed:
brew install openssl
gem install mysql2 -v '0.5.3' -- --with-ldflags=-L/usr/local/opt/openssl/lib
I was able to solve this problem with the following command:
gem install mysql2 -v '0.5.2' -- --with-cflags=\"-I/usr/local/opt/openssl/include\" --with-ldflags=\"-L/usr/local/opt/openssl/lib\"
and then
bundle install
UPDATE:
OpenSSL 1.0 reached EOL on 2019-12-31. After Mac OS and Homebrew packages upgrade you will need to specify paths to [email protected]
:
gem install mysql2 -v 0.5.2 -- --with-cflags=\"-I/usr/local/opt/[email protected]/include\" --with-ldflags=\"-L/usr/local/opt/[email protected]/lib\"