在 Linux 和 Ruby 1.9.2 上安装 MySQL-Ruby

在 Linux 和 Ruby 1.9.2 上安装 MySQL-Ruby

我在使用 Ruby 1.9.2 在 RedHat 4 上安装 MySQL-Ruby 时遇到了极大的困难。我使用公司代理,这几乎阻止任何软件包工具连接到外部存储库,因此“gem install mysql”无法解决问题。我尝试在本地安装 mysql-ruby gem,但失败了,并出现一个神秘的提示:

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

/ns/local/apps/internal/SWS/MetricsPublisher/ruby/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... yes
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. 

我也尝试按照随附的自述文件自行构建模块。结果:

$ruby extconf.rb --with-mysql-include=/path_to_my_sql_headers/mysql/include/ --with-mysql-lib=/path_to_my_sql_lib/mysql/lib/
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... yes
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.

有人有什么想法吗?坦率地说,我甚至不关心 MySQL-Ruby 是否具体工作,我只想通过 ruby​​ 1.9 中的 ruby​​ 调用以任何方式连接到 MySQL DB。谢谢。

答案1

bundler 通常会在 rails 中为我选择正确的软件包...我在之前安装的 ubuntu 中遇到了同样的问题,似乎我需要指定 ruby​​ 版本、体系结构和 mysql 版本作为 gem 名称的一部分,以便将其映射到我拥有的正确版本的库。还要确保在搜索路径和 ld 路径中安装了所有正确的依赖项

相关内容