gem安装错误:您必须先安装开发工具

我尝试安装gem'sinatra-websocket ',但是当我运行gem install sinatra-websocket ,我得到了这个错误…

ERROR: Failed to build gem native extension

… 随着 …

 C:/Ruby193/bin/ruby.exe extconf.rb checking for main() in -lc... *** 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:/Ruby193/bin/ruby --with-thin_parser-dir --without-thin_parser-dir --with-thin_parser-include --without-thin_parser-include=${thin_parser-dir}/include --with-thin_parser-lib --without-thin_parser-lib=${thin_parser-dir}/lib --with-clib --without-clib C:/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:/Ruby193/lib/ruby/1.9.1/mkmf.rb:461:in `try_link0' from C:/Ruby193/lib/ruby/1.9.1/mkmf.rb:476:in `try_link' from C:/Ruby193/lib/ruby/1.9.1/mkmf.rb:619:in `try_func' from C:/Ruby193/lib/ruby/1.9.1/mkmf.rb:845:in `block in have_library' from C:/Ruby193/lib/ruby/1.9.1/mkmf.rb:790:in `block in checking_for' from C:/Ruby193/lib/ruby/1.9.1/mkmf.rb:284:in `block (2 levels) in postpone' from C:/Ruby193/lib/ruby/1.9.1/mkmf.rb:254:in `open' from C:/Ruby193/lib/ruby/1.9.1/mkmf.rb:284:in `block in postpone' from C:/Ruby193/lib/ruby/1.9.1/mkmf.rb:254:in `open' from C:/Ruby193/lib/ruby/1.9.1/mkmf.rb:280:in `postpone' from C:/Ruby193/lib/ruby/1.9.1/mkmf.rb:789:in `checking_for' from C:/Ruby193/lib/ruby/1.9.1/mkmf.rb:840:in `have_library' from extconf.rb:4:in `<main>' 

以下是C:\Ruby193\lib\ruby\gems\1.9.1\gems\thin-1.6.3\ext\thin_parser

 "gcc -o conftest -IC:/Ruby193/include/ruby-1.9.1/i386-mingw32 -IC:/Ruby193/include/ruby-1.9.1/ruby/backward -IC:/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:/Ruby193/lib -L. -march=i486 -lmsvcrt-ruby191 -lshell32 -lws2_32 -limagehlp -lshlwapi " checked program was: /* begin */ 1: #include "ruby.h" 2: 3: #include <winsock2.h> 4: #include <windows.h> 5: int main(int argc, char **argv) 6: { 7: return 0; 8: } /* end */ 

我正在使用Windows 7。

为什么我得到错误? 有一句话说“不能创buildMakefile …”,但这是相关的吗?

Solutions Collecting From Web of "gem安装错误:您必须先安装开发工具"

你运行:

 xcode-select --install 

要安装Xcode开发人员工具?

听起来像你错过了红宝石devtools。

你可以在这里找到他们: http : //rubyinstaller.org/downloads/只需向下滚动到“开发工具包”。

下载并解压缩到任何你想要的地方。 在命令提示符下打开文件夹并运行ruby dk.rb init 。 这将创建一个配置文件详细说明您的红宝石安装。 检查这个配置文件,然后继续确认ruby安装的路径是正确的。

现在运行ruby dk.rb install 。 这将安装开发工具包。

重新启动命令提示符,并尝试再次安装gem。