我在尝试为Rails安装gem install mysql2 -v'0.3.17'时遇到了一些问题。当我尝试通过运行gem install mysql2 -v'0.3.17'或gem install mysql2 -v'0.3.17'来安装它时,它给出了以下错误:
ERROR: Error installing mysql2:
ERROR: Failed to build gem native extension.
Could not create Makefile due to some reason, probably lack of
necessary libraries and/or headers. Check the file for more
details. You may need configuration options.
Provided configuration options:
--with-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
--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-mysql-config
--without-mysql-config
Gem files will remain installed in `..../gems/ruby-1.9.3-p392/gems/mysql2-0.3.17 for inspection`.
Results logged to `.../gems/ruby-1.9.3-p392/extensions/x86_64-darwin-14/1.9.1/mysql2-0.3.17/gem_make.out`
如何修复此问题并成功安装mysql2?
谢谢大家。
答案 0 :(得分:10)
我在Ubuntu 15.04中,我得到了与上述相同的错误。
我做了:
<item
android:id="@+id/currency"
android:icon="@drawable/currency"
android:showAsAction="always"
android:title="rthrth">
<menu>
<group
android:id="@+id/currencies"
android:checkableBehavior="single" >
<item
android:id="@+id/us"
android:orderInCategory="1"
android:showAsAction="never"
android:title="@string/us"/>
<item
android:id="@+id/tr"
android:orderInCategory="2"
android:showAsAction="never"
android:title="@string/tr"/>
</group>
</menu>
</item>
在此之后我做了:
sudo apt-get install libmysqlclient-dev
现在我可以成功地做到了
gem install mysql2
没有任何错误。
答案 1 :(得分:8)
安装libmysqlclient-devel:
的CentOS / Fedora的:
yum install -y libmysqlclient-devel
Ubuntu的:
apt-get install -y libmysqlclient-dev
的Mac:
brew install mysql
希望它有所帮助。
答案 2 :(得分:3)
嗨,这可能有两个原因。
1)您没有为该尝试安装mysql服务器
$ brew install mysql
当您尝试使用尝试安装mysql2时,2)没有指定mysql_config
$ gem install mysql2 -- --with-mysql-config=/usr/local/Cellar/mysql/5.6.24/bin/mysql_config
答案 3 :(得分:2)
您需要先安装MySQL服务器。你现在可能没有它。