错误:错误安装mysql2:错误:未能建立宝石原生扩展。在Mac 10.12

问题描述 投票:3回答:4

我想类似的问题每一个解决方案:

近日,笔者从Ubuntu的转移到Mac和我试图安装在塞拉利昂mysql的宝石和我已经安装了Ruby,Rails的,MySQL后,,

也I型brew install mysql和它的工作下载MySQL,但不是宝石,所以我的问题是不相似。

我打这个mysql --version

和我mysql Ver 14.14 Distrib 5.7.16, for osx10.12 (x86_64) using EditLine wrapper

我试图安装mysql2创业板导轨建立一个新的应用程序

我打这个sudo gem install mysql2和得到这个错误:

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

current directory: /Users/mohammed.elias/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/mysql2-0.4.5/ext/mysql2
/Users/mohammed.elias/.rbenv/versions/2.4.0/bin/ruby -r ./siteconf20170102-2045-18gcs95.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 SSL_MODE_DISABLED in mysql.h... yes
checking for SSL_MODE_PREFERRED in mysql.h... yes
checking for SSL_MODE_REQUIRED in mysql.h... yes
checking for SSL_MODE_VERIFY_CA in mysql.h... yes
checking for SSL_MODE_VERIFY_IDENTITY in 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/5.7.16/lib
-----
creating Makefile

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

  /Users/mohammed.elias/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/extensions/x86_64-darwin-16/2.4.0-static/mysql2-0.4.5/mkmf.log

current directory:     /Users/mohammed.elias/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/mysql2-0.4.5/ext/mysql2
make "DESTDIR=" clean

current directory:     /Users/mohammed.elias/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/mysql2-0.4.5/ext/mysql2
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/mohammed.elias/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/mysq l2-0.4.5 for inspection.
Results logged to     /Users/mohammed.elias/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/extensions/x86_64-darwin-16/2.4.0-static/mysql2-0.4.5/gem_make.out
mysql ruby-on-rails ruby macos
4个回答
5
投票

很好地回答我的问题,并感谢@Holger刚刚提到这个问题上githup ld: library not found for -lssl` after Mac OS Sierra upgrade


3
投票

在新的MacBook Pro塞拉利昂安装MySQL2宝石时,有此相同的问题。

你需要改变你的环境变量包括以下内容(只是MySQL2宝石所需的版本替换0.0.00:

gem install mysql2 -v '0.0.00' -- --with-ldflags=-L/usr/local/opt/openssl/lib --with-cppflags=-I/usr/local/opt/openssl/include

此外,您$PATH应设置与庆典轮廓MySQL的,将被每次运行的bash的设置列表开始。您的bash配置文件可以在文件名.bash_profile下你的home目录中找到。如果不创建它,您可以创建使用命令nano .bash_profile文本文件(你应该在你的home目录(〜))。添加到您的bash配置文件:

export PATH="/usr/local/bin:/usr/local/sbin:/usr/local/mysql/bin:$PATH"

这条线将上面的目录添加到您的路径,包括MySQL路径。请确保您重新启动终端,如.bash_profile中只有当最初装载到终端上运行。


1
投票

由于某种原因,运行xcode-select --install,解决了这个问题对我来说。


0
投票

对于有人仍遇到的问题:

运行xcode-select --install将设置您的命令行工具

然后将这些构建运行下面的标志(本地应用程序):

bundle config --local build.mysql2 "--with-ldflags=-L/usr/local/opt/openssl/lib --with-cppflags=-I/usr/local/opt/openssl/include"

然后最后:bundle install安装mysql2宝石和其他宝石为我工作。

© www.soinside.com 2019 - 2024. All rights reserved.