【问题标题】:"Failed to build gem native extension" error when installing mysql2 on mac [duplicate]在 Mac 上安装 mysql2 时出现“无法构建 gem 原生扩展”错误 [重复]
【发布时间】:2014-05-18 08:39:38
【问题描述】:

我在我的 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

【问题讨论】:

    标签: mysql ruby


    【解决方案1】:

    错误消息显示`clang: error: unknown argument: '-multiply_definedsuppress' [-Wunused-command-line-argument-hard-error-in-future]。在安装时,编译器当前不接受选项 '-multiply_definedsuppress' 作为选项。你需要让你的编译器暂时接受它。

    根据Xcode 5.1 Release Notes

    Xcode 5.1 中的 Apple LLVM 编译器将无法识别的命令行选项视为错误。在构建 Python 原生扩展和 Ruby Gems 时已经出现了这个问题,其中当前指定了一些无效的编译器选项。 需要更改使用无效编译器选项的项目以删除这些选项。为了帮助简化这种转换,编译器将暂时接受将错误降级为警告的选项:-Wno-error=unused-command-line-argument-hard-error-in-future

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

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

    【讨论】:

    • 那个命令正好解决了我的问题。 gem 安装成功。非常感谢!
    猜你喜欢
    • 2017-05-16
    • 1970-01-01
    • 2013-11-14
    • 2019-04-03
    • 2011-04-06
    • 2015-03-06
    • 1970-01-01
    • 2020-10-16
    • 1970-01-01
    相关资源
    最近更新 更多