What to do about failed native extension builds in gem on Windows?

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-11 13:59:20

问题


A couple of Rails applications I downloaded have dependencies on bson_ext which appears to be a native code library. When I run rake gems:install for the app I get the following error message:

ERROR:  Error installing bson_ext:
        ERROR: Failed to build gem native extension.

d:/Ruby187/bin/ruby.exe extconf.rb
checking for asprintf()... no
checking for ruby/st.h... no
checking for st.h... no
checking for ruby/regex.h... no
checking for regex.h... no
checking for ruby/encoding.h... no
creating Makefile

make
'make' is not recognized as an internal or external command,
operable program or batch file.


Gem files will remain installed in d:/Ruby187/lib/ruby/gems/1.8/gems/bson_ext-1.0.1 for inspection.
Results logged to d:/Ruby187/lib/ruby/gems/1.8/gems/bson_ext-1.0.1/ext/cbson/gem_make.out

My questions are:

  1. Will my rails application fail because of this, I think I know the answer to this?

  2. If I need to build this gem can I do it on windows?

  3. If it can be built on Windows what toolchain do I need? GCC?

  4. Should I just abandon Windows for Rails development and use my Mac or a Linux VM instead?


回答1:


Try using RubyInstaller and the optional DevKit. With the DevKit installed you should be able to build (compile) most native extensions on windows.




回答2:


  1. Yes, this application won't start if one of the gems it depends on isn't installed. A gem that includes a native extension can't be installed unless the extension is compiled properly.
  2. Well, windows isn't the most supported OS in the ruby world :) but I think chances are you'll be able to.
  3. You'll need a C compiler and other tools like make. In most cases installing Visual Studio or Visual C++ is enough.
  4. This is highly recommended for any kind of more-or-less serious development. You are likely to encounter some nasty issues on windows. I myself have become as happy a developer as one could be since I've switched to mac :)



回答3:


Have you tried running Ruby from Cygwin?



来源:https://stackoverflow.com/questions/3155707/what-to-do-about-failed-native-extension-builds-in-gem-on-windows

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!