5

我为 Mac OS X Lion 安装了 MySQL 5.5.27(来自 .dmg)。

现在我尝试安装 mysql gem:

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

/Users/serg/.rvm/rubies/ree-1.8.7-head/bin/ruby extconf.rb
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lm... yes
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lz... yes
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lsocket... no
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lnsl... no
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lmygcc... no
checking for mysql_query() in -lmysqlclient... no
*** 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
    --without-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/serg/.rvm/rubies/ree-1.8.7-head/bin/ruby
    --with-mysql-config
    --without-mysql-config
    --with-mysql-dir
    --without-mysql-dir
    --with-mysql-include
    --without-mysql-include=${mysql-dir}/include
    --with-mysql-lib
    --without-mysql-lib=${mysql-dir}/lib
    --with-mysqlclientlib
    --without-mysqlclientlib
    --with-mlib
    --without-mlib
    --with-mysqlclientlib
    --without-mysqlclientlib
    --with-zlib
    --without-zlib
    --with-mysqlclientlib
    --without-mysqlclientlib
    --with-socketlib
    --without-socketlib
    --with-mysqlclientlib
    --without-mysqlclientlib
    --with-nsllib
    --without-nsllib
    --with-mysqlclientlib
    --without-mysqlclientlib
    --with-mygcclib
    --without-mygcclib
    --with-mysqlclientlib
    --without-mysqlclientlib


Gem files will remain installed in /Users/serg/.rvm/gems/ree-1.8.7-head/gems/mysql-2.8.1 for inspection.
Results logged to /Users/serg/.rvm/gems/ree-1.8.7-head/gems/mysql-2.8.1/ext/mysql_api/gem_make.out

我该如何解决?

4

3 回答 3

14

好的,这是我的解决方案:

1) I installed homebrew.
2) $ brew install mysql
3) $ gem install mysql

就这些。

于 2012-08-10T13:24:48.500 回答
4

看起来 gem 安装程序找不到您的 MySQL 库/头文件。

尝试指定 MySQL 目录,例如

gem install mysql -- --with-mysql-dir=/usr/local/mysql

(您可能需要弄清楚 MySQL 的 DMG 发行版的安装位置,YMMV。)

于 2012-08-09T10:57:45.657 回答
0
gem install mysql -- --with-mysql-dir=/usr/local/mysql
于 2013-05-09T18:31:30.330 回答