首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >Ruby gem mysql2安装失败

Ruby gem mysql2安装失败
EN

Stack Overflow用户
提问于 2010-11-07 04:57:12
回答 10查看 87.1K关注 0票数 80

当我尝试安装mysql2 gem时,它失败了,没有明显的错误。有没有人知道如何解决这个问题,以便安装mysql2?

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

/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby extconf.rb
checking for rb_thread_blocking_region()... no
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=/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/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 /Library/Ruby/Gems/1.8/gems/mysql2-0.2.6 for inspection.
Results logged to /Library/Ruby/Gems/1.8/gems/mysql2-0.2.6/ext/mysql2/gem_make.out
EN

回答 10

Stack Overflow用户

回答已采纳

发布于 2010-11-07 05:03:51

您的机器上必须安装64位MySQL,外加安装xcode时获得的构建工具。

票数 30
EN

Stack Overflow用户

发布于 2010-12-22 23:44:41

Ubuntu:

sudo apt-get install libmysqlclient-dev  #(mysql development headers)
sudo gem install mysql2 -- --with-mysql-dir=/etc/mysql/

就这样!

结果:

Building native extensions. This could take a while...
Successfully installed mysql2-0.2.6
1 gem installed
Installing ri documentation for mysql2-0.2.6...
Enclosing class/module 'mMysql2' for class Result not known
Enclosing class/module 'mMysql2' for class Client not known
Installing RDoc documentation for mysql2-0.2.6...
Enclosing class/module 'mMysql2' for class Result not known
Enclosing class/module 'mMysql2' for class Client not known
票数 150
EN

Stack Overflow用户

发布于 2010-11-07 05:10:33

mysql2需要MySQL开发头才能正确编译。这是必要的,因为大部分功能都是用C编写的,并随后链接到MySQL。

一种解决方案是将gem安装程序显式地指向mysql安装文件夹,如下所示

gem install mysql2 -- --with-mysql-dir=/usr/local/mysql
# or where ever you installed your mysql server to

或者通过将mysql服务器安装到已知位置(例如,通过使用homebrew)。然后安装gem

# install the mysql server locally
brew install mysql
# install the gem
gem install mysql2

这两种方法都需要安装XCode,才能安装所需的GCC编译器。

票数 41
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/4115126

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档