我在 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'
目前在安装时未被编译器接受为选项。您需要暂时让您的编译器接受它。
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/