Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ld: library not found for -lssl after Mac OS Sierra upgrade #795

Closed
rietta opened this issue Oct 17, 2016 · 70 comments
Closed

ld: library not found for -lssl after Mac OS Sierra upgrade #795

rietta opened this issue Oct 17, 2016 · 70 comments

Comments

@rietta
Copy link

rietta commented Oct 17, 2016

After upgrading to Sierra. Confirmed that OpenSSL and LibreSSL are installed through Homebrew. I'm continuing to troubleshoot.

gem install mysql2
Building native extensions.  This could take a while...
ERROR:  Error installing mysql2:
    ERROR: Failed to build gem native extension.

    /Users/frank/.rbenv/versions/2.2.4/bin/ruby -r ./siteconf20161017-40878-1pj8mbn.rb extconf.rb
checking for ruby/thread.h... yes
checking for rb_thread_call_without_gvl() in ruby/thread.h... yes
checking for rb_thread_blocking_region()... no
checking for rb_wait_for_single_fd()... yes
checking for rb_hash_dup()... yes
checking for rb_intern3()... yes
-----
Using mysql_config at /usr/local/bin/mysql_config
-----
checking for mysql.h... yes
checking for errmsg.h... yes
checking for mysqld_error.h... yes
-----
Don't know how to set rpath on your system, if MySQL libraries are not in path mysql2 may not load
-----
-----
Setting libpath to /usr/local/Cellar/mariadb/10.1.18/lib
-----
creating Makefile

make "DESTDIR=" clean

make "DESTDIR="
compiling client.c
compiling infile.c
compiling mysql2_ext.c
compiling result.c
compiling statement.c
linking shared-object mysql2/mysql2.bundle
ld: library not found for -lssl
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [mysql2.bundle] Error 1

make failed, exit code 2

Gem files will remain installed in /Users/frank/.rbenv/versions/2.2.4/lib/ruby/gems/2.2.0/gems/mysql2-0.4.4 for inspection.
Results logged to /Users/frank/.rbenv/versions/2.2.4/lib/ruby/gems/2.2.0/extensions/x86_64-darwin-16/2.2.0-static/mysql2-0.4.4/gem_make.out
@rietta rietta changed the title ld: library not found for -lssl after Mac OS Sierra upgrade ld: library not found for -lssl after Mac OS Sierra upgrade Oct 17, 2016
@rietta
Copy link
Author

rietta commented Oct 17, 2016

The solution was:
xcode-select --install

I really wish XCode would update without removing the command line tools every time without notice.

@rietta rietta closed this as completed Oct 17, 2016
@sodabrew
Copy link
Collaborator

Oh, glad you found it. Yeah, that's annoying every time. Maybe a specific check is in order? I wonder if xcode-select --print-path fails after an upgrade.

@swarajban
Copy link

Hm this didn't work for me still seeing same error

@rileytg
Copy link

rileytg commented Mar 17, 2017

This error occurred for me trying to install mysql2 gem with gem install mysql2

(posting this so hopefully future poor souls googling mysql2 install errors will see this...)

@Prendo93
Copy link

I encountered this error when using pip install MySQL-python.
Commenting here as the above solution worked (again for googlers)

@mavishou
Copy link

mavishou commented Aug 4, 2017

@rietta saves my life...

When the first time I try xcode-select --install, it says "can't install the software". Then I restart the computer and everything goes well.

@btoews
Copy link

btoews commented Aug 8, 2017

I have command line tools installed as well as Xcode 9. I tried reinstalling command line tools by mv /Library/Developer/CommandLineTools /Library/Developer/CommandLineTools.bak and running xcode-select --install again. I also tried a restart as suggested above, with no luck. Is there a way to tell it where openssl is installed?

$ gem install mysql2 -v '0.4.8'
Building native extensions.  This could take a while...
ERROR:  Error installing mysql2:
	ERROR: Failed to build gem native extension.

    current directory: /Users/mastahyeti/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/mysql2-0.4.8/ext/mysql2
/Users/mastahyeti/.rbenv/versions/2.3.3/bin/ruby -r ./siteconf20170808-1961-j6vuqi.rb extconf.rb
checking for rb_absint_size()... yes
checking for rb_absint_singlebit_p()... yes
checking for ruby/thread.h... yes
checking for rb_thread_call_without_gvl() in ruby/thread.h... yes
checking for rb_thread_blocking_region()... no
checking for rb_wait_for_single_fd()... yes
checking for rb_hash_dup()... yes
checking for rb_intern3()... yes
checking for rb_big_cmp()... yes
-----
Using mysql_config at /usr/local/bin/mysql_config
-----
checking for mysql.h... yes
checking for errmsg.h... yes
checking for mysqld_error.h... yes
checking for SSL_MODE_DISABLED in mysql.h... no
checking for MYSQL_OPT_SSL_ENFORCE in mysql.h... no
checking for MYSQL.net.vio in mysql.h... yes
checking for MYSQL.net.pvio in mysql.h... no
-----
Don't know how to set rpath on your system, if MySQL libraries are not in path mysql2 may not load
-----
-----
Setting libpath to /usr/local/Cellar/mysql@5.6/5.6.34/lib
-----
creating Makefile

To see why this extension failed to compile, please check the mkmf.log which can be found here:

  /Users/mastahyeti/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/extensions/x86_64-darwin-16/2.3.0-static/mysql2-0.4.8/mkmf.log

current directory: /Users/mastahyeti/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/mysql2-0.4.8/ext/mysql2
make "DESTDIR=" clean

current directory: /Users/mastahyeti/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/mysql2-0.4.8/ext/mysql2
make "DESTDIR="
compiling infile.c
compiling client.c
compiling mysql2_ext.c
compiling statement.c
compiling result.c
result.c:326:40: warning: incompatible pointer types assigning to 'my_bool *' (aka 'char *') from 'bool *' [-Wincompatible-pointer-types]
    wrapper->result_buffers[i].is_null = &wrapper->is_null[i];
                                       ^ ~~~~~~~~~~~~~~~~~~~~
result.c:328:40: warning: incompatible pointer types assigning to 'my_bool *' (aka 'char *') from 'bool *' [-Wincompatible-pointer-types]
    wrapper->result_buffers[i].error   = &wrapper->error[i];
                                       ^ ~~~~~~~~~~~~~~~~~~
2 warnings generated.
linking shared-object mysql2/mysql2.bundle
ld: library not found for -lssl
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [mysql2.bundle] Error 1

make failed, exit code 2

Gem files will remain installed in /Users/mastahyeti/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/mysql2-0.4.8 for inspection.
Results logged to /Users/mastahyeti/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/extensions/x86_64-darwin-16/2.3.0-static/mysql2-0.4.8/gem_make.out
$ xcode-select --install
xcode-select: error: command line tools are already installed, use "Software Update" to install updates

Update: I got it working after doing rbenv local 2.4.0. Not sure why this worked.

@fusco
Copy link

fusco commented Sep 2, 2017

exactly same error as @mastahyeti

Even after making a:

brew install openssl@1.1    

@fusco
Copy link

fusco commented Sep 2, 2017

come be back to ruby 2.4.0 and all works fine.

ps

  • MAC OSX 11 (high sierra, beta 8)
  • Xcode 9

@saberworks
Copy link

@rietta thank you. I installed perl with homebrew and then kept getting this error message when trying to install DBD::mysql. After running xcode-select --install DBD::mysql installed perfectly.

@dibowei
Copy link

dibowei commented Oct 16, 2017

Step 1.

brew install openssl

Step 2.

export LIBRARY_PATH=$LIBRARY_PATH:/usr/local/opt/openssl/lib/

@shiviser
Copy link

I had upgraded from Sierra to High Sierra a couple of weeks back. I received this error when I tried to install mysqlclient. After running xcode-select --install the problem disappeared. Thank you!

@jlnr
Copy link

jlnr commented Feb 5, 2018

Changing the $LIBRARY_PATH did not work for me, but this did:

sudo gem install mysql2 -- --with-cflags=\"-I/usr/local/opt/openssl/include\" --with-ldflags=\"-L/usr/local/opt/openssl/lib\"

@TysonRV
Copy link

TysonRV commented May 10, 2018

I had this error while trying to install the MySQL-python connector. Running xcode-select --install solved that immediately.

Thanks a lot for the info

@aHaydenLSS
Copy link

aHaydenLSS commented Jul 11, 2018

I've tried all of the above and nothing has worked. Please help! I think what is happening is the install is failing to find a mysql package. Specifically, one named -l-lpthread. See at the bottom of my error:

ERROR:  Error installing mysql2: 
ERROR: Failed to build gem native extension.

current directory: /Users/ahayden/.rvm/rubies/ruby-2.2.1/lib/ruby/gems/2.2.0/gems/mysql2-0.3.18/ext/mysql2
/Users/ahayden/.rvm/rubies/ruby-2.2.1/bin/ruby -r ./siteconf20180710-51697-9vnrlq.rb extconf.rb --with-cflags="-I/usr/local/opt/openssl/include" --with-ldflags="-L/usr/local/opt/openssl/lib"
checking for ruby/thread.h... yes
checking for rb_thread_call_without_gvl() in ruby/thread.h... yes
checking for rb_thread_blocking_region()... no
checking for rb_wait_for_single_fd()... yes
checking for rb_hash_dup()... yes
checking for rb_intern3()... yes
-----
Using mysql_config at /usr/local/bin/mysql_config
-----
checking for mysql.h... yes
checking for errmsg.h... yes
checking for mysqld_error.h... yes
-----
Don't know how to set rpath on your system, if MySQL libraries are not in path mysql2 may not load
-----
-----
Setting libpath to /usr/local/Cellar/mysql-connector-c/6.1.11/lib
-----
creating Makefile

current directory: /Users/ahayden/.rvm/rubies/ruby-2.2.1/lib/ruby/gems/2.2.0/gems/mysql2-0.3.18/ext/mysql2
make "DESTDIR=" clean

current directory: /Users/ahayden/.rvm/rubies/ruby-2.2.1/lib/ruby/gems/2.2.0/gems/mysql2-0.3.18/ext/mysql2
make "DESTDIR="
compiling infile.c
compiling client.c
compiling mysql2_ext.c
compiling result.c
linking shared-object mysql2/mysql2.bundle
ld: library not found for -l-lpthread
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [mysql2.bundle] Error 1

make failed, exit code 2

Gem files will remain installed in /Users/ahayden/.rvm/rubies/ruby-2.2.1/lib/ruby/gems/2.2.0/gems/mysql2-0.3.18 for inspection.
Results logged to /Users/ahayden/.rvm/rubies/ruby-2.2.1/lib/ruby/gems/2.2.0/extensions/x86_64-darwin-17/2.2.0/mysql2-0.3.18/gem_make.out

`

@TidbitSoftware
Copy link

TidbitSoftware commented Sep 8, 2018

Well this looks like a problem, -l-lpthread, which should read (unless this is just a printing error), -lpthread.

@markhallen
Copy link

Step 1.

brew install openssl

Step 2.

export LIBRARY_PATH=$LIBRARY_PATH:/usr/local/opt/openssl/lib/

Thank you @dibowei
I will never get those couple of hours back but you definitely saved me a few more!

@anthonybu
Copy link

Step 1.

brew install openssl

Step 2.

export LIBRARY_PATH=$LIBRARY_PATH:/usr/local/opt/openssl/lib/

Thank you very much @dibowei, same thing happened in OS X 10.14 Mojave, this fixed it.

@kigawas
Copy link

kigawas commented Oct 25, 2018

You can also try this on macOS

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

@sevaldes
Copy link

sevaldes commented Oct 25, 2018

Could be a solution setting multiple paths like -L/usr/local/opt/openssl/lib -L/usr/local/opt/mysql/lib but this regex only support use one path at a time. what do you think guys?

@jeremy
Copy link
Contributor

jeremy commented Oct 25, 2018

To fix for a manual gem install:

brew install openssl
gem install mysql2 -- --with-opt-dir="$(brew --prefix openssl)"

To fix for all bundle installs:

brew install openssl
bundle config --global build.mysql2 --with-opt-dir="$(brew --prefix openssl)"
bundle install

@chapmajs
Copy link

Step 1.

brew install openssl

Step 2.

export LIBRARY_PATH=$LIBRARY_PATH:/usr/local/opt/openssl/lib/

This thread ranks highly in Google. For other people arriving here after trying to get mysql2 gem going on OS X 10.14 Mojave, this did it for me. Stuck it in .bash_profile as well.

@sandeshdamkondwar
Copy link

Step 1.
brew install openssl
Step 2.
export LIBRARY_PATH=$LIBRARY_PATH:/usr/local/opt/openssl/lib/

This thread ranks highly in Google. For other people arriving here after trying to get mysql2 gem going on OS X 10.14 Mojave, this did it for me. Stuck it in .bash_profile as well.

Thank you so much, worked for me after all hit and tries.

@elavneet
Copy link

elavneet commented Jan 8, 2020

I have command line tools installed as well as Xcode 9. I tried reinstalling command line tools by mv /Library/Developer/CommandLineTools /Library/Developer/CommandLineTools.bak and running xcode-select --install again. I also tried a restart as suggested above, with no luck. Is there a way to tell it where openssl is installed?

$ gem install mysql2 -v '0.4.8'
Building native extensions.  This could take a while...
ERROR:  Error installing mysql2:
	ERROR: Failed to build gem native extension.

    current directory: /Users/mastahyeti/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/mysql2-0.4.8/ext/mysql2
/Users/mastahyeti/.rbenv/versions/2.3.3/bin/ruby -r ./siteconf20170808-1961-j6vuqi.rb extconf.rb
checking for rb_absint_size()... yes
checking for rb_absint_singlebit_p()... yes
checking for ruby/thread.h... yes
checking for rb_thread_call_without_gvl() in ruby/thread.h... yes
checking for rb_thread_blocking_region()... no
checking for rb_wait_for_single_fd()... yes
checking for rb_hash_dup()... yes
checking for rb_intern3()... yes
checking for rb_big_cmp()... yes
-----
Using mysql_config at /usr/local/bin/mysql_config
-----
checking for mysql.h... yes
checking for errmsg.h... yes
checking for mysqld_error.h... yes
checking for SSL_MODE_DISABLED in mysql.h... no
checking for MYSQL_OPT_SSL_ENFORCE in mysql.h... no
checking for MYSQL.net.vio in mysql.h... yes
checking for MYSQL.net.pvio in mysql.h... no
-----
Don't know how to set rpath on your system, if MySQL libraries are not in path mysql2 may not load
-----
-----
Setting libpath to /usr/local/Cellar/mysql@5.6/5.6.34/lib
-----
creating Makefile

To see why this extension failed to compile, please check the mkmf.log which can be found here:

  /Users/mastahyeti/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/extensions/x86_64-darwin-16/2.3.0-static/mysql2-0.4.8/mkmf.log

current directory: /Users/mastahyeti/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/mysql2-0.4.8/ext/mysql2
make "DESTDIR=" clean

current directory: /Users/mastahyeti/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/mysql2-0.4.8/ext/mysql2
make "DESTDIR="
compiling infile.c
compiling client.c
compiling mysql2_ext.c
compiling statement.c
compiling result.c
result.c:326:40: warning: incompatible pointer types assigning to 'my_bool *' (aka 'char *') from 'bool *' [-Wincompatible-pointer-types]
    wrapper->result_buffers[i].is_null = &wrapper->is_null[i];
                                       ^ ~~~~~~~~~~~~~~~~~~~~
result.c:328:40: warning: incompatible pointer types assigning to 'my_bool *' (aka 'char *') from 'bool *' [-Wincompatible-pointer-types]
    wrapper->result_buffers[i].error   = &wrapper->error[i];
                                       ^ ~~~~~~~~~~~~~~~~~~
2 warnings generated.
linking shared-object mysql2/mysql2.bundle
ld: library not found for -lssl
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [mysql2.bundle] Error 1

make failed, exit code 2

Gem files will remain installed in /Users/mastahyeti/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/mysql2-0.4.8 for inspection.
Results logged to /Users/mastahyeti/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/extensions/x86_64-darwin-16/2.3.0-static/mysql2-0.4.8/gem_make.out
$ xcode-select --install
xcode-select: error: command line tools are already installed, use "Software Update" to install updates

Update: I got it working after doing rbenv local 2.4.0. Not sure why this worked.

Thanks a lot man! 2.4.0 was the key. I was stuck for more than 2 days. :)

@Roninchen
Copy link

Step 1.

brew install openssl

Step 2.

export LIBRARY_PATH=$LIBRARY_PATH:/usr/local/opt/openssl/lib/

thank you bro!!!

@mobeenali12
Copy link

mobeenali12 commented Mar 26, 2020

if anyone is facing issue while installing mysqlclient in mac. Use this command.

LDFLAGS=-L/usr/local/opt/openssl/lib pip3 install mysqlclient

@NeenuAVarghese
Copy link

I faced the same issue in MAC OS Catalina. A slight variation of the above solutions/workarounds helped me solve the issue:
Step 1: brew install openssl (this installs openssl@1.1)
Step 2: export LIBRARY_PATH=$LIBRARY_PATH:/usr/local/opt/openssl\@1.1/lib/

@baraka2000
Copy link

Can;t install latest version of 0.3.21. 0.5 installs fine but doesn't work with my old app (rails 3.0). Same error as above but suggested fixes don;t work... Help us Obi-wan, you;re are only hope...

gem install mysql2 -v '0.3.21'
Building native extensions. This could take a while...
ERROR: Error installing mysql2:
ERROR: Failed to build gem native extension.

current directory: /Users/kevin/.rvm/gems/ruby-2.2.2/gems/mysql2-0.3.21/ext/mysql2

/Users/kevin/.rvm/rubies/ruby-2.2.2/bin/ruby -I /Users/kevin/.rvm/rubies/ruby-2.2.2/lib/ruby/site_ruby/2.2.0 -r ./siteconf20200330-84858-1tm56nc.rb extconf.rb
checking for ruby/thread.h... yes
checking for rb_thread_call_without_gvl() in ruby/thread.h... yes
checking for rb_thread_blocking_region()... no
checking for rb_wait_for_single_fd()... yes
checking for rb_hash_dup()... yes
checking for rb_intern3()... yes

Using mysql_config at /usr/local/bin/mysql_config

checking for mysql.h... yes
checking for errmsg.h... yes
checking for mysqld_error.h... yes

Setting rpath to /usr/local/Cellar/mysql/8.0.19/lib

creating Makefile

current directory: /Users/kevin/.rvm/gems/ruby-2.2.2/gems/mysql2-0.3.21/ext/mysql2
make "DESTDIR=" clean

current directory: /Users/kevin/.rvm/gems/ruby-2.2.2/gems/mysql2-0.3.21/ext/mysql2
make "DESTDIR="
compiling infile.c
compiling client.c
client.c:439:3: error: use of undeclared identifier 'my_bool'
my_bool res = mysql_read_query_result(client);
^
client.c:441:19: error: use of undeclared identifier 'res'
return (void *)(res == 0 ? Qtrue : Qfalse);
^
client.c:762:3: error: use of undeclared identifier 'my_bool'
my_bool boolval;
^
client.c:793:7: error: use of undeclared identifier 'boolval'
boolval = (value == Qfalse ? 0 : 1);
^
client.c:794:17: error: use of undeclared identifier 'boolval'
retval = &boolval;
^
client.c:797:10: error: use of undeclared identifier 'MYSQL_SECURE_AUTH'; did you mean 'MYSQL_DEFAULT_AUTH'?
case MYSQL_SECURE_AUTH:
^~~~~~~~~~~~~~~~~
MYSQL_DEFAULT_AUTH
/usr/local/Cellar/mysql/8.0.19/include/mysql/mysql.h:187:3: note: 'MYSQL_DEFAULT_AUTH' declared here
MYSQL_DEFAULT_AUTH,
^
client.c:798:7: error: use of undeclared identifier 'boolval'
boolval = (value == Qfalse ? 0 : 1);
^
client.c:799:17: error: use of undeclared identifier 'boolval'
retval = &boolval;
^
client.c:830:38: error: use of undeclared identifier 'boolval'
wrapper->reconnect_enabled = boolval;
^
client.c:1185:38: error: use of undeclared identifier 'MYSQL_SECURE_AUTH'; did you mean 'MYSQL_DEFAULT_AUTH'?
return _mysql_client_options(self, MYSQL_SECURE_AUTH, value);
^~~~~~~~~~~~~~~~~
MYSQL_DEFAULT_AUTH
/usr/local/Cellar/mysql/8.0.19/include/mysql/mysql.h:187:3: note: 'MYSQL_DEFAULT_AUTH' declared here
MYSQL_DEFAULT_AUTH,
^
10 errors generated.
make: *** [client.o] Error 1

make failed, exit code 2

Gem files will remain installed in /Users/kevin/.rvm/gems/ruby-2.2.2/gems/mysql2-0.3.21 for inspection.
Results logged to /Users/kevin/.rvm/gems/ruby-2.2.2/extensions/x86_64-darwin-19/2.2.0/mysql2-0.3.21/gem_make.out

@javiercornejo
Copy link

I had to re-link brew openssl library after xcode update. Read this for more info https://stackoverflow.com/a/39244687/2133399 thanks @rietta

@zorchan
Copy link

zorchan commented Apr 23, 2020

The solution was:
xcode-select --install

I really wish XCode would update without removing the command line tools every time without notice.

Thanks @rietta, still works in 2020. Kudos 👍

@rietta
Copy link
Author

rietta commented Apr 23, 2020

The solution was:
xcode-select --install
I really wish XCode would update without removing the command line tools every time without notice.

Thanks @rietta, still works in 2020. Kudos +1

Apple never fixes their bugs. Another exhibit is recovery console still goes to sleep during long running disk imaging operations with shenanigans to keep it awake. It's GOT ONE JOB TO DO!

@sanctuarium
Copy link

I had problem installing psycopg2 with error message

ld: library not found for -lssl
clang: error: linker command failed with exit code 1 (use -v to see invocation)
error: command 'gcc' failed with exit status 1

on macos Big Sur devBeta 2, xcode 12 Beta and command line tools all installed.

Step 1.
brew install openssl
Step 2.
export LIBRARY_PATH=$LIBRARY_PATH:/usr/local/opt/openssl/lib/

thank you bro!!!

solved the problem right away.

@aesyondu
Copy link

aesyondu commented Sep 11, 2020

Step 1.

brew install openssl

Step 2.

export LIBRARY_PATH=$LIBRARY_PATH:/usr/local/opt/openssl/lib/

Also helped me, many thanks!

I didn't realize brew was so buggy. I brew installed plantuml and suddenly couldn't get my existing rails application to work. I did bundle pristine --all as mentioned https://stackoverflow.com/a/59438200, and it showed a mysql2 error, which led me here. It also broke vim:

$ vim
dyld: Library not loaded: /usr/local/opt/python/Frameworks/Python.framework/Versions/3.7/Python
  Referenced from: /usr/local/bin/vim
  Reason: image not found
Abort trap: 6

Versions:
MacOS 10.14.6
gem install mysql2 -v '0.4.10'

@isopropylcyanide
Copy link

isopropylcyanide commented Sep 25, 2020

In my case, I was having trouble installing MySQL-python on python 2.7 with openssl@1.1. Taking cues from the above, I realized that the symlinks were not being passed properly. So I proceeded to link openssl manually

brew link openssl

This failed with a denied error, but prompted me the right steps

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"

I then passed the correct linker flags and it worked (later updated my bashrc)

sudo env LDFLAGS="-I/usr/local/opt/openssl@1.1/include -L/usr/local/opt/openssl@1.1/lib" pip install MySQL-python

image

Later, set the flags in your bash profiles. God damn, clang/openssl on Mac.

@rmuktader
Copy link

@dibowei I am trying to install Postgres, and your solution is what worked. How did you figure it out?

@iftheshoefritz
Copy link

iftheshoefritz commented Apr 23, 2021

If you're using openssl installed by homebrew natively on Apple Silicon, openssl@1.1/lib no longer lives at /usr/local/opt. For an architecture independent way of referring to openssl, try:

export LIBRARY_PATH=$LIBRARY_PATH:$(brew --prefix openssl@1.1)/lib/

@jsapp21
Copy link

jsapp21 commented Jun 15, 2021

Step 1.

brew install openssl

Step 2.

export LIBRARY_PATH=$LIBRARY_PATH:/usr/local/opt/openssl/lib/

@dibowei's solution worked but with modified for Apple M1
export LIBRARY_PATH=$LIBRARY_PATH:/opt/homebrew/Cellar/openssl@1.1/1.1.1k/lib

@joallard
Copy link

This solution deserves its own documentation repo, with different fixes for the platforms, along with PRs to fix them! 😄

@vin0010
Copy link

vin0010 commented Jul 12, 2021

Changing the $LIBRARY_PATH did not work for me, but this did:

sudo gem install mysql2 -- --with-cflags=\"-I/usr/local/opt/openssl/include\" --with-ldflags=\"-L/usr/local/opt/openssl/lib\"

I use Mac os Catalina 10.15.7 (19H524). This worked for me. Thank you.

@vinay0x
Copy link

vinay0x commented Aug 6, 2021

Step 1.

brew install openssl

Step 2.

export LIBRARY_PATH=$LIBRARY_PATH:/usr/local/opt/openssl/lib/

This worked for me. Thanks!

@TejasS2021
Copy link

Step 1.

brew install openssl

Step 2.

export LIBRARY_PATH=$LIBRARY_PATH:/usr/local/opt/openssl/lib/

This worked !! Thanks!!

@ia-eh
Copy link

ia-eh commented Jan 7, 2022

Step 1.

brew install openssl

Step 2.

export LIBRARY_PATH=$LIBRARY_PATH:/usr/local/opt/openssl/lib/

That also worked for me on intel mac with MacOS Monterrey installed

@joostholslag
Copy link

Since the default shell on MacOS is now zsh the fixes in this thread no longer worked. It did work after changing the shell to bash. I hope my pain will help others.

@wintnandarthein128
Copy link

Step 1.

brew install openssl

Step 2.

export LIBRARY_PATH=$LIBRARY_PATH:/usr/local/opt/openssl/lib/

This is really work.Thank you so much.

@edubevilacqua
Copy link

MacOS Monterey

Check your installed mysql version(i'm using 8.0.28_1)
ls /opt/homebrew/Cellar/mysql

Change the bundle.mysql2 config (change '8.0.28_1' for the mysql installed version)

bundle config build.mysql2 -- \ --with-mysql-lib=/opt/homebrew/Cellar/mysql/8.0.28_1/lib \ --with-mysql-dir=/opt/homebrew/Cellar/mysql/8.0.28_1 \ --with-mysql-config=/opt/homebrew/Cellar/mysql/8.0.28_1/bin/mysql_config \ --with-mysql-include=/opt/homebrew/Cellar/mysql/8.0.28_1/include

Run:
bundle install

@LadyKerr
Copy link

MacOS Monterey

Check your installed mysql version(i'm using 8.0.28_1) ls /opt/homebrew/Cellar/mysql

Change the bundle.mysql2 config (change '8.0.28_1' for the mysql installed version)

bundle config build.mysql2 -- \ --with-mysql-lib=/opt/homebrew/Cellar/mysql/8.0.28_1/lib \ --with-mysql-dir=/opt/homebrew/Cellar/mysql/8.0.28_1 \ --with-mysql-config=/opt/homebrew/Cellar/mysql/8.0.28_1/bin/mysql_config \ --with-mysql-include=/opt/homebrew/Cellar/mysql/8.0.28_1/include

Run: bundle install

@edubevilacqua this just worked for macOS Sonoma! Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests