无法在Mac OS X上安装mysql gem [英] Can't install mysql gem on Mac OS X

查看:114
本文介绍了无法在Mac OS X上安装mysql gem的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用安装程序从 http://dev.mysql.com/downloads/mysql安装了MySQL服务器。然后,按照几个指南中的解释,我想用以下命令安装mysql gem。

  sudo gem install mysql 

这不起作用,并提供以下输出。

 构建原生扩展。这可能需要一段时间... 
错误:安装mysql时出错:
错误:无法构建gem本机扩展。

/Users/luzi/.rvm/rubies/ruby-1.9.3-p429/bin/ruby extconf.rb --with-mysql-dir = / usr / local / mysql /
检查mysql_ssl_set()... *** extconf.rb失败***
由于某种原因无法创建Makefile,可能缺少
必需的库和/或头文件。查看mkmf.log文件以获取更多
的详细信息。您可能需要配置选项。

提供的配置选项:
--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 / luzi / .rvm / rubies / ruby​​-1.9.3-p429 / bin / ruby​​
--with-mysql-config
--without-mysql-config
/Users/luzi/.rvm/rubies/ruby-1.9.3-p429/lib/ruby/1.9.1/mkmf.rb:381:in`try_do':The编译器无法生成可执行文件。 (RuntimeError)
您必须先安装开发工具。来自/ Users / luzi的/Users/luzi/.rvm/rubies/ruby-1.9.3-p429/lib/ruby/1.9.1/mkmf.rb:461:in`try_link0'
中的
/.rvm/rubies/ruby-1.9.3-p429/lib/ruby/1.9.1/mkmf.rb:476:in`try_link'
from /Users/luzi/.rvm/rubies/ruby-1.9 .3-p429 / lib / ruby​​ / 1.9.1 / mkmf.rb:619:在`try_func'
from /Users/luzi/.rvm/rubies/ruby-1.9.3-p429/lib/ruby/ 1.9.1 / mkmf.rb:894:在`block in have_func'
from /Users/luzi/.rvm/rubies/ruby-1.9.3-p429/lib/ruby/1.9.1/mkmf.rb :790:在`block in check_for'
from /Users/luzi/.rvm/rubies/ruby-1.9.3-p429/lib/ruby/1.9.1/mkmf.rb:284:in`block( 2级)推迟'
from /Users/luzi/.rvm/rubies/ruby-1.9.3-p429/lib/ruby/1.9.1/mkmf.rb:254:in`open'
from /Users/luzi/.rvm/rubies/ruby-1.9.3-p429/lib/ruby/1.9.1/mkmf.rb:284:in`block in block'
from / Users / luzi / .rvm / rubies / ruby​​-1.9.3-p429 / lib / ruby​​ / 1.9.1 / mkmf.rb:254:从/Users/luzi/.rvm/rubies/ruby-1.9开启
。 3-429页/ LIB /红宝石/ 1.9.1 / mkmf.rb:280:ⅰ n`从/Users/luzi/.rvm/rubies/ruby-1.9.3-p429/lib/ruby/1.9.1/mkmf.rb:789:in`checking_for'
从/延迟
/Users/luzi/.rvm/rubies/ruby-1.9.3-p429/lib/ruby/1.9.1/mkmf.rb:893:in`have_func'
from extconf.rb:45:in`< ; main>'


Gem文件将保留安装在/Users/luzi/.rvm/gems/ruby-1.9.3-p429/gems/mysql-2.9.1中进行检查。
记录到/Users/luzi/.rvm/gems/ruby-1.9.3-p429/gems/mysql-2.9.1/ext/mysql_api/gem_make.out

我几次重新安装ruby 1.9.3。 XCode命令行实用程序也已安装。我也用自制软件安装了mysql服务器(没有带任何东西)。



我也试过了上面命令的一些选项,比如 - -with-mysql-dir = / usr / local / mysql - with-mysql-config = / usr / local / mysql / bin / mysql_config 。传入标志( sudo env ARCHFLAGS = - arch x86_64gem install mysql )并没有帮助。



更新



我也尝试了mysql2 gem,导致出现相同的错误,可能是因为mysql2 gem依赖于
$ b

更新2



mkmf.log
$ b

 / opt / local / bin / gcc-apple-4.2  - o conftest -I / Users / luzi / .rvm / rubies / ruby​​-1.9.3-p429 / include / ruby​​-1.9.1 / x86_64-darwin12.4.0 -I / Users / luzi / .rvm / rubies / ruby​​-1.9 .3-p429 / include / ruby​​-1.9.1 / ruby​​ / backward -I / Users / luzi / .rvm / rubies / ruby​​-1.9.3-p429 / include / ruby​​-1.9.1 -I。-D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -I / opt / local / include -I / usr / local / mysql / include -Wno-null-conversion -Os -g -fno-strict-aliasing -arch x86_64 -O3 -ggdb -Wall -Wextra -Wno-unused-参数-Wno-括号-Wno-long-long -Wno-missing-field-initializers -Winterinter-arith -Wwrite-strings -Wdeclaration-aft er-statement -Wshorten-64-to-32 -Wimplicit-function-declaration -fno-common -pipe conftest.c -L。 -L / Users / luzi / .rvm / rubies / ruby​​-1.9.3-p429 / lib -L ​​/ opt / local / lib -L。 -L / usr / local / lib -L ​​/ opt / local / lib -L ​​/ usr / local / mysql / lib -lmysqlclient -lruby.1.9.1 -lpthread -ldl -lobjc
cc1:error:unrecognized命令行选项-Wno-null-conversion
checked程序是:
/ * begin * /
1:#includeruby.h
2:
3:int main(int argc,char ** argv)
4:{
5:return 0;
6:}
/ * end * /


解决方案

这里解释问题:http://www.randomactsofsentience.com/2013/05/gem-install-mysql2-missing-mysqlh简单地说:



更改文件 / usr / local / mysql / bin / mysql_config code>>第120行

  cflags = -  I $ pkgincludedir -Wall -Wno-null-conversion -Wno- unused-private-field -Os -g -fno-strict-aliasing -DDBUG_OFF -arch x86_64#note:end space!
cxxflags = - I $ pkgincludedir -Wall -Wno-null-conversion - Wno-unused-private-field -Os -g -fno-strict-aliasing -DDBUG_OFF -arch x86_64#note:end space!

  cflags = -  I $ pkgincludedir -Wall -Os -g -fno-strict-aliasing -DDBUG_OFF -arch x86_64#note:end space! 
cxxflags = - I $ pkgincludedir -Wall -Os -g -fno-strict-aliasing -DDBUG_OFF -arch x86_64#note:end space!


I installed the MySQL server with the installer from http://dev.mysql.com/downloads/mysql. Then, as explained in several guides, I wanted to install the mysql gem with the following command.

sudo gem install mysql

This is not working and gives the following output.

Building native extensions.  This could take a while...
ERROR:  Error installing mysql:
    ERROR: Failed to build gem native extension.

        /Users/luzi/.rvm/rubies/ruby-1.9.3-p429/bin/ruby extconf.rb --with-mysql-dir=/usr/local/mysql/
checking for mysql_ssl_set()... *** 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/luzi/.rvm/rubies/ruby-1.9.3-p429/bin/ruby
    --with-mysql-config
    --without-mysql-config
/Users/luzi/.rvm/rubies/ruby-1.9.3-p429/lib/ruby/1.9.1/mkmf.rb:381:in `try_do': The compiler failed to generate an executable file. (RuntimeError)
You have to install development tools first.
    from /Users/luzi/.rvm/rubies/ruby-1.9.3-p429/lib/ruby/1.9.1/mkmf.rb:461:in `try_link0'
    from /Users/luzi/.rvm/rubies/ruby-1.9.3-p429/lib/ruby/1.9.1/mkmf.rb:476:in `try_link'
    from /Users/luzi/.rvm/rubies/ruby-1.9.3-p429/lib/ruby/1.9.1/mkmf.rb:619:in `try_func'
    from /Users/luzi/.rvm/rubies/ruby-1.9.3-p429/lib/ruby/1.9.1/mkmf.rb:894:in `block in have_func'
    from /Users/luzi/.rvm/rubies/ruby-1.9.3-p429/lib/ruby/1.9.1/mkmf.rb:790:in `block in checking_for'
    from /Users/luzi/.rvm/rubies/ruby-1.9.3-p429/lib/ruby/1.9.1/mkmf.rb:284:in `block (2 levels) in postpone'
    from /Users/luzi/.rvm/rubies/ruby-1.9.3-p429/lib/ruby/1.9.1/mkmf.rb:254:in `open'
    from /Users/luzi/.rvm/rubies/ruby-1.9.3-p429/lib/ruby/1.9.1/mkmf.rb:284:in `block in postpone'
    from /Users/luzi/.rvm/rubies/ruby-1.9.3-p429/lib/ruby/1.9.1/mkmf.rb:254:in `open'
    from /Users/luzi/.rvm/rubies/ruby-1.9.3-p429/lib/ruby/1.9.1/mkmf.rb:280:in `postpone'
    from /Users/luzi/.rvm/rubies/ruby-1.9.3-p429/lib/ruby/1.9.1/mkmf.rb:789:in `checking_for'
    from /Users/luzi/.rvm/rubies/ruby-1.9.3-p429/lib/ruby/1.9.1/mkmf.rb:893:in `have_func'
    from extconf.rb:45:in `<main>'


Gem files will remain installed in /Users/luzi/.rvm/gems/ruby-1.9.3-p429/gems/mysql-2.9.1 for inspection.
Results logged to /Users/luzi/.rvm/gems/ruby-1.9.3-p429/gems/mysql-2.9.1/ext/mysql_api/gem_make.out

I reinstalled ruby 1.9.3 several times. The XCode command line utilities are installed, too. I installed the mysql server with homebrew, too (didn't bring anything).

I also tried some options for the command above, like --with-mysql-dir=/usr/local/mysql and --with-mysql-config=/usr/local/mysql/bin/mysql_config. Passing in flags (sudo env ARCHFLAGS="-arch x86_64" gem install mysql) didn't help neither.

UPDATE:

I also tried the mysql2 gem, with the result of the same error appearing, probably because the mysql2 gem is dependent on the mysql gem.

UPDATE 2:

Content of mkmf.log:

"/opt/local/bin/gcc-apple-4.2 -o conftest -I/Users/luzi/.rvm/rubies/ruby-1.9.3-p429/include/ruby-1.9.1/x86_64-darwin12.4.0 -I/Users/luzi/.rvm/rubies/ruby-1.9.3-p429/include/ruby-1.9.1/ruby/backward -I/Users/luzi/.rvm/rubies/ruby-1.9.3-p429/include/ruby-1.9.1 -I. -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE   -I/opt/local/include -I/usr/local/mysql/include  -Wno-null-conversion -Os -g -fno-strict-aliasing -arch x86_64  -O3 -ggdb -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wshorten-64-to-32 -Wimplicit-function-declaration  -fno-common -pipe conftest.c  -L. -L/Users/luzi/.rvm/rubies/ruby-1.9.3-p429/lib -L/opt/local/lib -L. -L/usr/local/lib -L/opt/local/lib     -L/usr/local/mysql/lib -lmysqlclient  -lruby.1.9.1  -lpthread -ldl -lobjc "
cc1: error: unrecognized command line option "-Wno-null-conversion"
checked program was:
/* begin */
1: #include "ruby.h"
2: 
3: int main(int argc, char **argv)
4: {
5:   return 0;
6: }
/* end */

解决方案

The problem is explained here: http://www.randomactsofsentience.com/2013/05/gem-install-mysql2-missing-mysqlh-on-os.html. In short:

Change the file /usr/local/mysql/bin/mysql_config around line 120

cflags="-I$pkgincludedir  -Wall -Wno-null-conversion -Wno-unused-private-field -Os -g -fno-strict-aliasing -DDBUG_OFF -arch x86_64 " #note: end space!
cxxflags="-I$pkgincludedir  -Wall -Wno-null-conversion -Wno-unused-private-field -Os -g -fno-strict-aliasing -DDBUG_OFF -arch x86_64 " #note: end space!

to

cflags="-I$pkgincludedir  -Wall -Os -g -fno-strict-aliasing -DDBUG_OFF -arch x86_64 " #note: end space!
cxxflags="-I$pkgincludedir  -Wall -Os -g -fno-strict-aliasing -DDBUG_OFF -arch x86_64 " #note: end space!

这篇关于无法在Mac OS X上安装mysql gem的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆