2012-08-09 113 views
3

我为Mac OS X Lion(来自.dmg)安装了MySQL 5.5.27。gem install mysql:无法构建gem原生扩展(Mac Lion)

现在,我尝试安装mysql的宝石:

$ 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 

我该如何解决呢?

回答

12

欧凯,这里是我的解决方案:

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

这是所有。

+1

在Linux上:'sudo apt-get install libmysql-ruby libmysqlclient-dev' – 2013-10-16 18:23:31

4

它看起来像宝石安装程序无法找到您的MySQL库/标题。

尝试指定MySQL目录,例如

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

(您可能需要搞清楚的是安装了MySQL的DMG分布在哪里,情况因人而异)

+0

我试过你的解决方案,它不起作用。相同的输出。 – ExiRe 2012-08-09 11:01:17

+2

你可以给创业板的安装路径mysql_config: '宝石安装mysql - --with-mysql的-配置=在/ usr /本地/ MySQL的/斌/ mysql_config' – jstr 2012-08-09 11:06:38

+0

遗憾的是它并没有太多的工作: 检查mysql_ssl_set()...没有 检查rb_str_set_len()...没有 检查rb_thread_start_timer()...没有 检查mysql.h ...没有 检查mysql/mysql.h .. 。no *** extconf.rb失败***' – ExiRe 2012-08-09 11:08:12

0
gem install mysql -- --with-mysql-dir=/usr/local/mysql 
相关问题