【问题标题】:Error Installing Mysql2 on OSX在 OSX 上安装 Mysql2 时出错
【发布时间】:2017-02-26 21:40:26
【问题描述】:

正在尝试安装特定版本的 Mysql2 Gem。我明白了:

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

    /usr/local/var/rbenv/versions/2.2.3/bin/ruby -r ./siteconf20161017-56699-1dsu6v9.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/mysql/5.7.16/lib
-----
creating Makefile

make "DESTDIR=" clean

make "DESTDIR="
compiling client.c
compiling infile.c
compiling mysql2_ext.c
compiling result.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

作为参考,我事先运行了brew install mysql,它运行成功。我还尝试卸载所有版本的brew 的mysql 引用以防万一。

我有什么遗漏吗?我环顾四周,大多数页面都指向确保您运行 brew install mysql,我有。

如果我对上述解释不太清楚,我遇到的失败是在成功运行brew install mysql 之后,错误是因为之后尝试通过gem install mysql2 -v '0.3.20' 安装 gem

有什么想法吗? 谢谢

【问题讨论】:

  • @msmith 让我们知道上述 ref 对您的影响
  • 这和我做的一样,我用brew成功安装了它,但是之后我实际上无法成功安装gem IE gem install mysql -v '0.3.20'

标签: mysql macos rubygems


【解决方案1】:

如何让它在 MacOS Mojave 上运行。

确保openssl 已通过 Homebrew 安装在 Mac 上:

brew install openssl

然后按照这种特殊方式安装mysql2 gem:

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

其中 x.x.x - mysql2 gem 的指定版本。

【讨论】:

  • 在 Catalina 上也为我工作过。我在 ~/.zshrc 中将标志设置为 LDFLAGS="-L/usr/local/opt/openssl@1.1/lib" 和 CPPFLAGS="-I/usr/local/opt/openssl@1.1/include"但我猜是版本错误,或者无论如何都没有做到这一点。
【解决方案2】:

仅供参考,最终工作的是xcode-select --install,它似乎安装了处理ld: library not found for -lssl问题的OpenSSL库。

【讨论】:

    猜你喜欢
    • 2012-01-18
    • 2014-04-16
    • 2011-05-02
    • 1970-01-01
    • 2011-09-11
    • 2016-10-23
    • 1970-01-01
    • 2014-12-21
    • 2011-08-11
    相关资源
    最近更新 更多