我在 64 位 CentOS 机器上安装 mysql ruby gem 时遇到问题。
[jacekb@vitaidealn ~]$ uname -a
Linux vitaidealn.local 2.6.18-92.el5 #1 SMP Tue Jun 10 18:51:06 EDT 2008 x86_64 x86_64 x86_64 GNU/Linux
已安装 Mysql 和 mysql-devel 包。Mysql_config 提供以下路径:
Usage: /usr/lib64/mysql/mysql_config [OPTIONS]
Options:
--cflags [-I/usr/include/mysql -g -pipe -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -fno-strict-aliasing -fwrapv]
--include [-I/usr/include/mysql]
--libs [-L/usr/lib64/mysql -lmysqlclient -lz -lcrypt -lnsl -lm -L/usr/lib64 -lssl -lcrypto]
--libs_r [-L/usr/lib64/mysql -lmysqlclient_r -lz -lpthread -lcrypt -lnsl -lm -lpthread -L/usr/lib64 -lssl -lcrypto]
--socket [/var/lib/mysql/mysql.sock]
--port [3306]
--version [5.0.45]
--libmysqld-libs [-L/usr/lib64/mysql -lmysqld -lz -lpthread -lcrypt -lnsl -lm -lpthread -lrt -L/usr/lib64 -lssl -lcrypto]
尝试安装:
[jacekb@vitaidealn ~]$ gem install mysql -- --with-mysql-include=/usr/include/mysql --with-mysql-libs=/usr/lib64/mysql
...
ERROR: Error installing mysql:
ERROR: Failed to build gem native extension.
/usr/bin/ruby extconf.rb --with-mysql-include=/usr/include/mysql --with-mysql-libs=/usr/lib64/mysql
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lm... no
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lz... no
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
*** 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.
我将非常感激您的帮助。谢谢阅读 :)。
答案1
我认为您需要 mysql-client 的 devel 包。尝试使用以下命令安装它:
yum install mysql-devel
答案2
我写了一个博客文章很久以前就听说过这个。抱歉打扰了 ;-)
答案是运行
gem install mysql -- --with-mysql-conf=/usr/bin/mysql --with-mysql-lib=/usr/lib/mysql
显然,您必须使用 lib64 路径。也许这也会对您有所帮助。
你可能想知道 EPEL 中有一个 ruby-mysql 包。看看这个可能会很有趣 :)
答案3
尝试这个:
1. yum uninstall mysql
2. yum install mysql
3. yum install mysql-devel (to install development libraries, For Debian, Knoppix, Buildix user apt-get install libmysqlclient15-dev)
4. gem install mysql
答案4
在我的场景中它起作用了
sudo gem install mysql -- --with-mysql-config=/usr/local/mysql/bin/mysql_config