mysql - 在mac上安装mysql2时出现"Failed to build gem native extension"错误

标签 mysql ruby

我在 Mac 的终端中安装 mysql2,但出现错误消息。有谁知道如何解决这个问题?非常感谢!

我的osx版本是10.9并且已经安装了Xcode和命令行工具。

joe@~ $sudo gem install mysql2
Password:
Building native extensions.  This could take a while...
ERROR:  Error installing mysql2:
ERROR: Failed to build gem native extension.

/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/ruby 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()... yes
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/5.6.17/lib
-----
creating Makefile

make "DESTDIR="
compiling client.c
compiling infile.c
compiling mysql2_ext.c
compiling result.c
linking shared-object mysql2/mysql2.bundle
clang: error: unknown argument: '-multiply_definedsuppress' [-Wunused-command-line-argument-hard-error-in-future]
clang: note: this will be a hard error (cannot be downgraded to a warning) in the future
make: *** [mysql2.bundle] Error 1


Gem files will remain installed in /Library/Ruby/Gems/2.0.0/gems/mysql2-0.3.15 for inspection.
Results logged to /Library/Ruby/Gems/2.0.0/gems/mysql2-0.3.15/ext/mysql2/gem_make.out

最佳答案

错误消息显示,`clang:错误:未知参数:'-multiply_definesuppress' [-Wunused-command-line-argument-hard-error-in-future]。看来选项 '-multiply_definesuppress' 目前在安装时未被编译器接受为选项。您需要暂时让您的编译器接受它。

根据Xcode 5.1 Release Notes :

The Apple LLVM compiler in Xcode 5.1 treats unrecognized command-line options as errors. This issue has been seen when building both Python native extensions and Ruby Gems, where some invalid compiler options are currently specified. Projects using invalid compiler options will need to be changed to remove those options. To help ease that transition, the compiler will temporarily accept an option to downgrade the error to a warning: -Wno-error=unused-command-line-argument-hard-error-in-future

因此,您可能想尝试运行:

ARCHFLAGS=-Wno-error=unused-command-line-argument-hard-error-in-future gem install mysql2

关于mysql - 在mac上安装mysql2时出现"Failed to build gem native extension"错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22889798/

相关文章:

ruby - 遍历列表 Ruby 时如何跳过元素

ruby - 如何将 Ruby 博客添加到 Rails 3 应用程序

ruby - 是否可以在回形针中将附件设为可选?

php - 字符编码和数据库

mysql - 如何使用 Play、MySQL 和 Hibernate 自定义查询 ManyToMany 表?

mysql - Laravel 4 数据库语句创建触发器

python - 将 zipfile 提取代码从 ruby​​ 转换为 python

mysql - 从 SQL 表中删除条目以及关系的正确方法

mysql - 循环 mysql_real_connect 或者什么

ruby - Sinatra 不理解 config.ru 中的设置?