windows 下安装部分gem时出现 Could not create Makefile due to some reason 的解决办法

Mac系统安装Rails 最近有门课要写一个简单的Web应用,以前写Web都是用Java写的,想想这次还是用Ruby On Rails写算了,能节省很多时间。由于Ruby电脑上已经有了,所以直接安装Rails就可以了。 sudo gem install rails 阅读详情

现象描述:

如果你安装某个需要本地编译代码的gem 时出现了类似如下的错误,则符合本文章所谈论的情况:

C:/Develop/Ruby193/bin/ruby.exe extconf.rb 
checking for asprintf()... *** 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.

Provided configuration options:
	--with-opt-dir
	--without-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
	--srcdir=.
	--curdir
	--ruby=C:/Develop/Ruby193/bin/ruby
C:/Develop/Ruby193/lib/ruby/1.9.1/mkmf.rb:381:in `try_do': The compiler failed to generate an executable file. (RuntimeError)
You have to install development tools first.
	from C:/Develop/Ruby193/lib/ruby/1.9.1/mkmf.rb:461:in `try_link0'
	from C:/Develop/Ruby193/lib/ruby/1.9.1/mkmf.rb:476:in `try_link'
	from C:/Develop/Ruby193/lib/ruby/1.9.1/mkmf.rb:619:in `try_func'
	from C:/Develop/Ruby193/lib/ruby/1.9.1/mkmf.rb:894:in `block in have_func'
	from C:/Develop/Ruby193/lib/ruby/1.9.1/mkmf.rb:790:in `block in checking_for'
	from C:/Develop/Ruby193/lib/ruby/1.9.1/mkmf.rb:284:in `block (2 levels) in postpone'
	from C:/Develop/Ruby193/lib/ruby/1.9.1/mkmf.rb:254:in `open'
	from C:/Develop/Ruby193/lib/ruby/1.9.1/mkmf.rb:284:in `block in postpone'
	from C:/Develop/Ruby193/lib/ruby/1.9.1/mkmf.rb:254:in `open'
	from C:/Develop/Ruby193/lib/ruby/1.9.1/mkmf.rb:280:in `postpone'
	from C:/Develop/Ruby193/lib/ruby/1.9.1/mkmf.rb:789:in `checking_for'
	from C:/Develop/Ruby193/lib/ruby/1.9.1/mkmf.rb:893:in `have_func'
	from extconf.rb:3:in `<main>'

mkmf.log中的内容是:

"gcc -o conftest -IC:/Develop/Ruby193/include/ruby-1.9.1/i386-mingw32 -IC:/Develop/Ruby193/include/ruby-1.9.1/ruby/backward -IC:/Develop/Ruby193/include/ruby-1.9.1 -I. -DFD_SETSIZE=2048  -DFD_SETSIZE=2048  -O3 -fno-omit-frame-pointer -g -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wimplicit-function-declaration conftest.c  -L. -LC:/Develop/Ruby193/lib -L.      -lmsvcrt-ruby191  -lshell32 -lws2_32 -limagehlp -lshlwapi  "
In file included from C:/Develop/Ruby193/include/ruby-1.9.1/ruby.h:32:0,
                 from conftest.c:1:
C:/Develop/Ruby193/include/ruby-1.9.1/ruby/ruby.h:109:14: error: size of array 'ruby_check_sizeof_voidp' is negative
In file included from C:/Develop/Ruby193/include/ruby-1.9.1/ruby.h:32:0,
                 from conftest.c:1:
C:/Develop/Ruby193/include/ruby-1.9.1/ruby/ruby.h: In function 'rb_class_of':
C:/Develop/Ruby193/include/ruby-1.9.1/ruby/ruby.h:1333:12: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
C:/Develop/Ruby193/include/ruby-1.9.1/ruby/ruby.h: In function 'rb_type':
C:/Develop/Ruby193/include/ruby-1.9.1/ruby/ruby.h:1349:12: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
In file included from C:/Develop/Ruby193/include/ruby-1.9.1/ruby/ruby.h:1381:0,
                 from C:/Develop/Ruby193/include/ruby-1.9.1/ruby.h:32,
                 from conftest.c:1:
C:/Develop/Ruby193/include/ruby-1.9.1/ruby/missing.h: At top level:
C:/Develop/Ruby193/include/ruby-1.9.1/ruby/missing.h:41:8: error: redefinition of 'struct timespec'
In file included from c:\develop\devkit\mingw\bin\../lib/gcc/x86_64-w64-mingw32/4.7.2/../../../../x86_64-w64-mingw32/include/process.h:12:0,
                 from C:/Develop/Ruby193/include/ruby-1.9.1/ruby/win32.h:62,
                 from C:/Develop/Ruby193/include/ruby-1.9.1/ruby/defines.h:223,
                 from C:/Develop/Ruby193/include/ruby-1.9.1/ruby/ruby.h:67,
                 from C:/Develop/Ruby193/include/ruby-1.9.1/ruby.h:32,
                 from conftest.c:1:
c:\develop\devkit\mingw\bin\../lib/gcc/x86_64-w64-mingw32/4.7.2/../../../../x86_64-w64-mingw32/include/sys/types.h:89:8: note: originally defined here
In file included from C:/Develop/Ruby193/include/ruby-1.9.1/ruby/ruby.h:1381:0,
                 from C:/Develop/Ruby193/include/ruby-1.9.1/ruby.h:32,
                 from conftest.c:1:
C:/Develop/Ruby193/include/ruby-1.9.1/ruby/missing.h:48:8: error: redefinition of 'struct timezone'
In file included from C:/Develop/Ruby193/include/ruby-1.9.1/ruby/win32.h:63:0,
                 from C:/Develop/Ruby193/include/ruby-1.9.1/ruby/defines.h:223,
                 from C:/Develop/Ruby193/include/ruby-1.9.1/ruby/ruby.h:67,
                 from C:/Develop/Ruby193/include/ruby-1.9.1/ruby.h:32,
                 from conftest.c:1:
c:\develop\devkit\mingw\bin\../lib/gcc/x86_64-w64-mingw32/4.7.2/../../../../x86_64-w64-mingw32/include/time.h:260:8: note: originally defined here
checked program was:
/* begin */
1: #include "ruby.h"
2: 
3: #include <winsock2.h>
4: #include <windows.h>
5: int main() {return 0;}
/* end */


问题原因和解决办法:

可能你安装了和你使用的Ruby版本不对应的Devkit。

参考 http://rubyinstaller.org/downloads/ ,页面上有这样几行

WHICH DEVELOPMENT KIT?

Down this page, several and different versions of Development Kits (DevKit) are listed. Please download the right one for your version of Ruby:

Ruby 1.8.6 to 1.9.3: tdm-32-4.5.2
Ruby 2.0.0: mingw64-32-4.7.2
Ruby 2.0.0 x64 (64bits): mingw64-64-4.7.2
请下载和安装正确的DevKit


相关问题链接:

如果你在试图安装mysql有关的gem时出现类似问题,请阅读这篇帖子,看看是否能对你的问题有帮助。

http://www.ruby-forum.com/topic/1112530

另外,rubyinstaller也提供了很多有用的TroubleShooting

https://github.com/oneclick/rubyinstaller/wiki/Troubleshooting#wiki-gems_fails_comspec_autorun

https://github.com/oneclick/rubyinstaller/wiki/Troubleshooting#dll-conflicts-with-devkit-cause-native-gem-install-failures

Simulink Test Sequence实战:5步搞定复杂逻辑测试(附Excel模板) 本文详细介绍了如何利用Simulink Test Sequence模块高效完成复杂逻辑测试。通过对比传统Excel方法的不足,阐述了Test Sequence以流程图和自然语言描述测试场景的优势,并提供了从环境搭建、逻辑构建到与Test Manager集成、利用Excel模板进行数据驱动的完整5步实战指南,帮助工程师将复杂的状态机或逻辑流测试从繁琐的‘体力活’转变为高效的‘技术活’。 阅读详情

相关推荐

目标检测数据集 第069期-基于yolo标注格式的玻璃清洁状态检测数据集(含免费分享)

但这类技术的落地,离不开大量标注规范、场景丰富的数据集作为算法训练的支撑,玻璃清洁状态检测数据集的出现,正是为了满足这一市场与技术需求。在高校与科研机构的计算机视觉研究中,该数据集可作为基础研究素材,用于探索物体状态识别的算法优化方向,比如针对玻璃这类透明物体的检测算法改进,或是小样本场景下的状态识别研究。通过摄像头采集车窗、挡风玻璃的图像,算法自动检测玻璃清洁度,若识别到脏污影响视线,及时提醒运维人员清洁,避免因玻璃脏污引发的安全事故,提升交通出行的安全性。

深度学习算法工程师,专注于前沿算法研究与实战应用。在这里,我将分享深度学习领域的实战经验、优质数据集资源以及最新论文解读与精度分析,旨在与广大技术爱好者共同探索人工智能的奥秘,助力技术成长与创新。 128

ios 开发环境常见问题合集

文章目录Unable to add a source with url `https://github.com/CocoaPods/Specs.git` named `cocoapods`.错误场景解决方法Could not create Makefile due to some reason, probably lack of necessary libraries and/or headers错误场景解决方法安装rvm安装ruby安装cocoapodsrequirements_osx_brew_libs

adojayfan的博客 1862

CentOS 7/8 系统下,基于Docker Compose一键部署Dify AI应用平台

本文详细介绍了在CentOS 7/8系统下,使用Docker Compose一键部署Dify AI应用平台的完整流程。从系统环境准备、Docker引擎安装与加速配置,到获取Dify项目、关键环境变量设置,再到服务启动、状态监控及初始化访问,提供了手把手的部署指南和常见问题排查方法,帮助用户快速搭建稳定、可维护的AI应用开发环境。

q5r6s7的博客 139

could not create makefile due to some reason probably lack of necessary cocoapods

cocopods 安装失败。 解决办法: 因为macos自带的ruby版本较老导致。安装rvm。 How to upgrade Ruby versions for your Ruby on Rails app (satchel.works) 升级cocoapods到2.7.4。 成功。

千里之行始于足下 2239

如何在高版本的ubuntu系统里安装gcc4.1.2

1、下载安装包,一共五个http://archive.ubuntu.com/ubuntu/pool/universe/g/gcc-4.1/,根据计算机系统位数   进行下载,64位下载amd64结尾的。开头分别是cpp-4.1_4.1.2、g++-4.1_4.1.2、gcc-4.1-base_4.1.2、gcc-     4.1_4.1.2、libstdc++6-4.1 2、使用sudo d

lsr_fighting的博客 1931

量化交易新手入门:从零开始搭建你的第一个Python交易策略(附完整代码)

本文为量化交易新手提供从零开始搭建Python双均线策略的完整指南,涵盖环境配置、数据获取、策略实现及风险管理等关键步骤。通过详细的代码示例和实践建议,帮助读者快速掌握量化交易的核心技术,并避免常见陷阱。文章特别强调Python在量化交易中的技术革新优势,适合希望进入金融科技领域的初学者。

weixin_26905487的博客 444

gem安装报错

在ubuntu11.04上安装mysql2的gem是报错   *** 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 detai...

cinic2003 734

究竟什么是虚拟同步机???虚拟同步机巨简单理解

同步发电机定子铁芯的内圆均匀分布着定子槽,槽内按一定规律嵌放着对称的三相绕组U1-U2、V1-V2、W1-W2,如图1所示。工作原理转子铁芯上装有制成一定形状的成对磁极,磁极上绕有励磁绕组。励磁绕组上通直流电时,会在电机的气隙中形成极性相间的分布磁场,称为励磁磁场。当原动机拖动转子以恒定速度旋转时,励磁磁场随转轴一起旋转并顺次切割定子各相绕组。定子电枢绕组中将会感应出大小和方向周期性变化的三相对称正弦感应电动势。各相电动势大小相等,相位各差120°。

weixin_53126442的博客 2609

runtime无法执行grep_编译器无法生成可执行文件。 (RuntimeError)

I recently upgraded to OS Mountain Lion. A project I'm working on requires gem sys-proctable as a dependency, but when I run bundle install I get:Fetching gem metadata from https://rubygems.org/.........

weixin_39614831的博客 985

C#与欧姆龙PLC 通信——fins udp协议

该调试助手专门为了帮助大家学习以及测试Fins-Udp通信,下面进行详细介绍。

qq_34059233的博客 2876

康耐视visionpro-CogCreateSegmentAvgSegsTool操作工具详细说明

康耐视visionpro-CogCreateSegmentAvgSegsTool操作工具详细说明

视觉人机器视觉的博客 1480

mysql bundle 安装_执行Bundle安装时MySql出错

当我执行Bundle Install时,出现以下错误:Installing mysql2 (0.3.10) with native extensionsGem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension./Users/manish/.rvm/rubies/ruby-1.9.2-p290/b...

weixin_39602108的博客 327

ros_gz_bridge__镜像__readme

Run。

1113

rails mysql 中文报错_gem-windous环境下rails连接mysql报错

用railsinstaller装的环境依赖的ruby rails devkit sqlite3都装过了现在想试试mysqlC:\windows\system32>rails new E:\ruby\kk10 -d mysqlInstalling mysql2 (0.3.13)Gem::Installer::ExtensionBuildError: ERROR: Failed to build...

weixin_36301830的博客 104

怀旧版电脑GBC模拟器

再现原版GBC掌机的界面,电脑运行连游戏界面都一样大小,很怀旧,很真实,(英文版)强烈推荐,很小的文件,很难才找到的。

迈瑞BS系列全自动生化分析仪LIS协议接口手册(内含HL7和ASTM)

迈瑞BS系列全自动生化分析仪LIS协议接口手册,内含HL7和ASTM)

gem安装pg遇到问题

gem安装pg遇到问题 安装pg遇到问题 #gem  install   pg 报错信息为: Building native extensions.  This could take a while... ERROR:  Error installing pg:     ERROR: Failed to build gem native extension.   

li_yong_kuan的专栏 1450

IDEA的使用指南

IDEA基于java的使用手册,可以最快速的上手,在使用中不断的丰富自己的使用技巧.

Ubuntu Ruby Ruby-install chruby rails 环境配置

原文网址:https://ryanbigg.com/2014/10/ubuntu-ruby-ruby-install-chruby-and-youUbuntu,Ruby,ruby-install,chruby,Rails和You2014年10月5日最后更新:2017年7月13日本初学者指南将使用chruby + ruby​​-install和Rails 5.1.2为您的机器设置Ruby 2.4.1...

liguangxianbin的博客 461

ET2012新版免狗免安装绿色软件

ET2012新版免狗免安祖昂绿色软件。,新界面,新视觉,

mysql出错2_【gem安装】mysql2错误

错误信息Gem::Ext::BuildError:ERROR:Failedtobuildgemnativeextension./home/jaylin/.rvm/rubies/ruby-2.2.1/bin/ruby-r./siteconf20150423-6190-1ocfncu.rbextconf.rbcheckingforruby/thread.h...yeschec...

weixin_36227730的博客 466

Docker redmine 安装 redmine_ckeditor 插件失败解决办法

在 Redmine Docker 容器中安装 redmine_ckeditor ,按照官方的步骤进行安装,报错,不成功。1、 从官网 https://github.com/a-ono/redmine_ckeditor/archive/master.zip 下载zip包。2、解压并修改文件名:   $ unzip master.zip $ mv redmine_ckedit...

gogo1217的专栏 1286

安装Rails踩过的坑

安装ruby on rails时遇到的坑,慢慢踩,慢慢收集 错误: ERROR: Failed to build gem native extension. /usr/bin/ruby extconf.rb mkmf.rb can't find header files for ruby at /usr/share/include/ruby.h 解决办法: 1.Linux Ce...

Jimy_Fengqi 607

gem安装软件时遇到的问题以及解决思路

今天需要在由于工作需要,需要使用bundle install来更新依赖包,本以为很顺利,结果遇到了下面的一堆问题,在此进行记录并分享自己遇到这个问题时的思路:问题一:用gem安装ruby的包时出错root@kali:~/Desktop#geminstallnokogiri-v'1.6.8.1' Buildingnativeextensions.Thisco...

weixin_34292402的博客 1768

ruby 安装mysql报错,extconf.rb

[root@localhost ruby-1.9.2-p180]# gem install mysql Building native extensions.  This could take a while... ERROR:  Error installing mysql:         ERROR: Failed to build gem native extension. /

KEN的专栏 3593

GNU makefile 教程

最近在学习Linux下的C编程,买了一本叫《Linux环境下的C编程指南》读到makefile就越看越迷糊,可能是我的理解能不行。 于是google到了以下这篇文章。通俗易懂。然后把它贴出来,方便学习。 后记,看完发现这篇文章和《Linux环境下的C编程指南》的makefile一章所讲述的惊人的相似,只是这篇文章从一个实例切入,在有些地方比较好理解。能让人看懂就是好文章。 跟我一起写 M

在梦中享一刻静谧,等待梦中的你 826

ruby 安装mysql_ruby 安装mysql报错,extconf.rb

[root@localhost ruby-1.9.2-p180]# gem install mysqlBuilding native extensions. This could take a while...ERROR: Error installing mysql:ERROR: Failed to build gem native extension./usr/local/bin/ruby...

weixin_42134117的博客 280

gawk: error while loading shared libraries: libreadline.so.6:

平台编译报错,错误现象比较奇怪 checking for working htonl... yes configure: creating ./config.status config.status: creating Makefile gawk: error while loading shared libraries: libreadline.so.6: cannot open sh

风之伤 5222
上一篇: Disable/Enable Ribbon Buttons for MFC Feature Pack
woncomp
博客等级 码龄19年 2粉丝 2原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值