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 · 28 comments

Comments

Projects
None yet
@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

This comment has been minimized.

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 Oct 17, 2016

@sodabrew

This comment has been minimized.

Copy link
Collaborator

sodabrew commented Oct 17, 2016

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

This comment has been minimized.

Copy link

swarajban commented Dec 8, 2016

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

@rileytg

This comment has been minimized.

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

This comment has been minimized.

Copy link

Prendo93 commented Jun 28, 2017

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

krlmlr added a commit to r-dbi/RMariaDB that referenced this issue Jul 24, 2017

@mavishou

This comment has been minimized.

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.

@mastahyeti

This comment has been minimized.

Copy link

mastahyeti 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

This comment has been minimized.

Copy link

fusco commented Sep 2, 2017

exactly same error as @mastahyeti

Even after making a:

brew install openssl@1.1    
@fusco

This comment has been minimized.

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

This comment has been minimized.

Copy link

saberworks commented Sep 19, 2017

@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

This comment has been minimized.

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

This comment has been minimized.

Copy link

shiviser commented Oct 23, 2017

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

This comment has been minimized.

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

This comment has been minimized.

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

This comment has been minimized.

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

This comment has been minimized.

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

This comment has been minimized.

Copy link

markhallen commented Sep 28, 2018

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

This comment has been minimized.

Copy link

anthonybu commented Oct 16, 2018

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

This comment has been minimized.

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"
@darkunter

This comment has been minimized.

Copy link

darkunter 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

This comment has been minimized.

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

This comment has been minimized.

Copy link

chapmajs commented Nov 17, 2018

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

This comment has been minimized.

Copy link

sandeshdamkondwar commented Nov 22, 2018

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.

@jbodah

This comment has been minimized.

Copy link

jbodah commented Dec 6, 2018

Mojave upgrade borked this for me. My libs post-upgrade (wiping xcode, reinstalling, yadayada):

$ ls /usr/local/lib/ | grep ssl
libevent_openssl-2.1.6.dylib
libevent_openssl.a
libevent_openssl.dylib

exporting LIBRARY_PATH worked for me; reconfiguring bundler did not, brew link --force did not (complaining about overriding OSX controlled libs that don't actually exist). Didn't try upgrading Homebrew, but that's probably worth giving a go

@ninjacn

This comment has been minimized.

Copy link

ninjacn commented Dec 29, 2018

Step 1.

brew install openssl

Step 2.

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

非常感谢

@nafihnfh

This comment has been minimized.

Copy link

nafihnfh commented Dec 30, 2018

The solution was:
xcode-select --install

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

when i run xcode-select --install i get error
xcode-select: error: command line tools are already installed, use "Software Update" to install updates

@spiderpug

This comment has been minimized.

Copy link

spiderpug commented Jan 5, 2019

when i run xcode-select --install i get error
xcode-select: error: command line tools are already installed, use "Software Update" to install updates

Same for me on Mojave, but this solution #795 (comment) worked fine

@sstawecki

This comment has been minimized.

Copy link

sstawecki commented Jan 24, 2019

Posting this comment just to share my experience and help other people.
I fixed this error by uninstalling and installing mysql formula from homebrew, I suspect the error was originated by updating to macOS Mojave.
My old mysql version was 5.7.22 and after reinstalling mysql it was 8.0.13, so had to install an older version mysql@5.7 and then brew link.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment