2012-02-07 81 views
3

为了在mac上构建ruby 1.9,我必须安装gcc 4.6。 Rails和一堆其他的宝石都很好。安装mysql或mysql2给了我各种心痛。在Mac Lion上构建mysql2 gem的错误w/rvm&ruby 1.9.3

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标志不支持。任何人都有一个想法,提供这些编译选项,所以我可以删除这个标志?或者任何其他解决方案....谢谢

回答

5

从安装rails时分开安装MySQL。我试图用rvm来安装它,但它不起作用。

看看这个article它应该帮助你安装MySQL

如果失败,这里的另一个solution。两者都为我工作。

+0

谢谢。我一直在我的系统上运行mysql多年。我只是从红宝石1.8.x升级到1.9和有问题的mysql2驱动程序。我想我可以从头重新安装MySQL,看看是否有帮助。 – farhadf 2012-02-07 17:19:18

+0

是的,应该做的窍门让我知道如果它不工作 – coletrain 2012-02-08 03:19:36

+0

这对我也使用山狮。谢谢 – Adam 2012-07-18 10:13:22

-3

无法构建gem原生扩展不是关于gem依赖关系,而是关于应用程序没有完全安装。

我面临同样的问题,这应该做的伎俩:

sudo apt-get install libmysql-ruby libmysqlclient-dev

+1

这是Ubuntu的。他要求适用于MacOS – 2012-12-28 03:37:25

+0

apt-get是不支持OSX – 2013-04-29 00:24:51

3

好,因为你生活在边缘... -arch标志应该是-m64,而不是现在...所以你需要更新你的mysql_config来反映这个变化在我这上线128取代:

-arch x86_64 

-m64 

然后,

gem install mysql2 
+0

其中mysql_config位于何处? – NullVoxPopuli 2012-02-21 15:25:47

+0

谢谢!这在升级Snow Leopard上的Ruby 1.8.7-> 1.9.3时帮助了我。我甚至没有重新安装mysql,只用: 'env ARCHFLAGS =“ - m64”gem install mysql - --with-mysql-config =/usr/local/mysql/bin/mysql_config' – Gnomet 2012-09-20 12:49:39

15

我想在此发布的所有解决方案,但没有运气。我通过几次自制软件重新安装了mysql,但仍然没有运气。然后我遇到了一个解决方案的博客文章。

我编辑了mysql_config文件中/usr/local/Cellar/mysql/5.6.12/bin并取消了W-编译器选项-Wno-null-conversion-Wno-unused-private-fieldcflagscxxflags

这解决了问题gem install mysql2

参考:randomactsofsentience.com/2013/05/gem-install-mysql2-missing-mysqlh-on-os

+0

花了差不多2对这个问题,直到我发现了这个解决方案,麦片:) – kasperite 2013-06-25 02:46:25

+0

对我来说工作时间!谢谢! – daybreaker 2013-07-02 18:39:42

+0

适合我。谢谢。 – Anil 2013-07-15 01:45:27

相关问题