我正在尝试安装mysql2:
sudo gem install mysql2 -v '0.2.7' -- --with-mysql-config=/usr/local/Cellar/mysql/5.5.25a/bin/mysql_config我得到了这个错误:
ERROR: Error installing mysql2:
ERROR: Failed to build gem native extension.
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby extconf.rb -- with-mysql-config=/usr/local/Cellar/mysql/5.5.25a/bin/mysql_config
checking for rb_thread_blocking_region()... no
checking for mysql.h... no
checking for mysql/mysql.h... no
-----
mysql.h is missing. please check your installation of mysql and try again.
-----
*** 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是通过brew安装的,因此我的mysql.h文件位于:
/usr/local/Cellar/mysql/5.5.25a/bin/mysql_config这就是为什么我有with-mysql-config标志的原因
mysql_config文件在以下位置查找mysql.h文件:
$basedir/include/mysql/mysql.h需要补充的是,我更新了来自
gem的mysql2
到gem 'mysql2','0.2.7‘
因为,我收到了一些关于mysql2 0.3.*不支持活动记录的事实的弃用警告。所以要么升级rails到3.1,要么降级mysql2。我选择了后者。
我应该编辑mysql_config吗?或者我还可以做些什么来解决这个问题?谢谢你的帮助。
发布于 2013-06-28 22:23:29
我意识到这是一个古老的问题,但对于任何从谷歌来到这里的人来说,我发现这个解决方案对我很有效:http://www.randomactsofsentience.com/2013/05/gem-install-mysql2-missing-mysqlh-on-os.html。
简短的版本是从第120行的/usr/local/Cellar/mysql/5.6.12/bin/mysql_config中删除编译器标志-Wno-null-conversion -Wno-unused-private-field (将mysql版本替换为找到该文件所需的任何内容)。
我在OSX上使用自制的mysql和rvm,使用ruby 1.9.3。
发布于 2012-11-09 06:43:23
你应该安装mysql-dev包,这里有一些编译本地驱动的头文件。
https://stackoverflow.com/questions/13299113
复制相似问题