ruby - 在带有 rvm 和 ruby​​ 1.9.3 的 Mac Lion 上构建 mysql2 gem 时出错

标签 ruby osx-lion rvm mysql2

为了在 mac 上构建 ruby​​ 1.9,我必须安装 gcc 4.6。 Rails 和一堆其他的 gem 构建得很好。安装 mysql 或 mysql2 让我心痛不已。

rubygems> env ARCHFLAGS="-arch x86_64" gem install mysql2 -- --with-mysql-dir=/usr/local/mysql --with-mysql-lib=/usr/local/mysql/lib --with-mysql-include=/usr/local/mysql/include --with-mysql-config=/usr/local/mysql/bin/mysql_config
Building native extensions.  This could take a while...
ERROR:  Error installing mysql2:
    ERROR: Failed to build gem native extension.
        /Users/ff/.rvm/rubies/ruby-1.9.3-p0/bin/ruby extconf.rb --with-mysql-dir=/usr/local/mysql --with-mysql-lib=/usr/local/mysql/lib --with-mysql-include=/usr/local/mysql/include --with-mysql-config=/usr/local/mysql/bin/mysql_config
checking for rb_thread_blocking_region()... yes
checking for rb_wait_for_single_fd()... yes
checking for mysql.h... no
checking for mysql/mysql.h... no
-----
mysql.h is missing.  please check your installation of mysql and try again.
-----
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of
necessary libraries and/or headers.  Check the mkmf.log file for more
details.  You may need configuration options.

Provided configuration options:
    --with-opt-dir
    --with-opt-include
    --without-opt-include=${opt-dir}/include
    --with-opt-lib
    --without-opt-lib=${opt-dir}/lib
    --with-make-prog
    --without-make-prog
    --srcdir=.
    --curdir
    --ruby=/Users/ff/.rvm/rubies/ruby-1.9.3-p0/bin/ruby
    --with-mysql-config


Gem files will remain installed in /Users/ff/.rvm/gems/ruby-1.9.3-p0/gems/mysql2-0.3.11 for inspection.
Results logged to /Users/ff/.rvm/gems/ruby-1.9.3-p0/gems/mysql2-0.3.11/ext/mysql2/gem_make.out

当我查看 mkmf.log 文件时,我看到:


have_header: checking for mysql.h... -------------------- no

"/opt/local/bin/gcc-mp-4.6 -E -I/Users/ff/.rvm/rubies/ruby-1.9.3-p0/include/ruby-1.9.1/x86_64-darwin11.2.0 -I/Users/ff/.rvm/rubies/ruby-1.9.3-p0/include/ruby-1.9.1/ruby/backward -I/Users/ff/.rvm/rubies/ruby-1.9.3-p0/include/ruby-1.9.1 -I. -I/Users/ff/.rvm/usr/include -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE   -I/usr/local/mysql/include -Os -arch i386 -fno-common  -O3 -ggdb -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wimplicit-function-declaration  -fno-common -pipe  conftest.c -o conftest.i"
gcc-mp-4.6: error: i386: No such file or directory
gcc-mp-4.6: error: unrecognized option '-arch'
checked program was:
/* begin */
1: #include "ruby.h"
2: 
3: #include <mysql.h>
/* end */

所以基本上似乎不支持 -arch 标志。任何人都知道这些编译选项在哪里提供,以便我可以删除此标志?或任何其他解决方案....谢谢

最佳答案

我尝试了这里发布的所有解决方案,但并不走运。我通过自制软件重新安装了 mysql 几次,但仍然没有运气。然后我看到了一篇包含解决方案的博文。

我编辑了 /usr/local/Cellar/mysql/5.6.12/bin 中的 mysql_config 文件并删除了 W-编译器选项 -Wno- cflagscxxflags 的 null-conversion-Wno-unused-private-field

这解决了 gem install mysql2 的问题。

引用:randomactsofsentience.com/2013/05/gem-install-mysql2-missing-mysqlh-on-os

关于ruby - 在带有 rvm 和 ruby​​ 1.9.3 的 Mac Lion 上构建 mysql2 gem 时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9169719/

相关文章:

ruby - 卸载工头

ruby - Mongomapper 和 Sinatra 未定义方法 `update_attributes' 为 nil :NilClass

php - 如何在 OSX Lion 上启用 PHP 错误?

OS X 上的 Android SDK 安装文件夹

ruby-on-rails - 使用 rvm1-capistrano3 安装 Ruby

ruby - 使用 YARD 时忽略注释掉的代码

ruby - Rails 3 模型记录器

gcc - "...can' t 在使用 gcc 编译 Python C 扩展时找出...的架构类型问题

ruby - 查找最新可用的 RVM 版本号

ruby - 使用 rvm 离线安装 Ruby