gem install:无法构建gem原生扩展名(无法找到头文件) [英] gem install: Failed to build gem native extension (can't find header files)
问题描述
我使用的是Fedora 14,我安装并运行了MySQL和MySQL服务器5.1.42。
现在我试图以root用户身份执行此操作:
gem install mysql
但是我得到这个错误:
构建原生扩展。这可能需要一段时间...
错误:安装mysql时出错:
错误:无法构建gem本机扩展。
/ usr / bin / ruby extconf.rb
mkmf.rb在/usr/lib/ruby/ruby.h找不到头文件
Gem文件将保留安装在/usr/lib/ruby/gems/1.8/gems/mysql-2.8.1中进行检查。
结果记录到/usr/lib/ruby/gems/1.8/gems/mysql-2.8.1/ext/mysql_api/gem_make.out
这里有什么问题?在安装红宝石1.8.7。和最新的rubygems 1.3.7。
对于那些可能被接受的答案困惑的人,我也是,你也是需要安装ruby头文件[ ruby-devel ]。
保存我的皮肤的文章是 here 。
这是修改后的解决方案(请注意,我在Fedora 13上):
yum - 安装gcc mysql-devel ruby-devel rubygems
$ p
gem install -y mysql - --with-mysql-config = / usr / bin / mysql_config
$ b对于使用Debian风格的包装的Debian和其他发行版,安装ruby开发头文件为:
sudo apt-get install ruby-dev
对于Ubuntu,ruby开发头文件是通过以下方式安装:
sudo apt-get install ruby-all-dev
如果您使用的是早期版本的ruby(如2.2),那么您需要运行:
sudo apt-get install ruby2.2-dev
(其中2.2是你想要的Ruby版本)
I am using Fedora 14 and I have MySQL and MySQL server 5.1.42 installed and running. Now I tried to do this as root user:
gem install mysql
But I get this error:
Building native extensions. This could take a while... ERROR: Error installing mysql: ERROR: Failed to build gem native extension. /usr/bin/ruby extconf.rb mkmf.rb can't find header files for ruby at /usr/lib/ruby/ruby.h Gem files will remain installed in /usr/lib/ruby/gems/1.8/gems/mysql-2.8.1 for inspection. Results logged to /usr/lib/ruby/gems/1.8/gems/mysql-2.8.1/ext/mysql_api/gem_make.out
What's wrong here? In installed ruby 1.8.7. and the latest rubygems 1.3.7.
解决方案For those who may be confused by the accepted answer, as I was, you also need to have the ruby headers installed [ruby-devel].
The article that saved my hide is here.
And this is the revised solution (note that I'm on Fedora 13):
yum -y install gcc mysql-devel ruby-devel rubygems gem install -y mysql -- --with-mysql-config=/usr/bin/mysql_config
For Debian, and other distributions using Debian style packaging the ruby development headers are installed by:
sudo apt-get install ruby-dev
For Ubuntu the ruby development headers are installed by:
sudo apt-get install ruby-all-dev
If you are using a earlier version of ruby (such as 2.2), then you will need to run:
sudo apt-get install ruby2.2-dev
(where 2.2 is your desired Ruby version)
这篇关于gem install:无法构建gem原生扩展名(无法找到头文件)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!