GEM安装错误:您必须先安装开发工具(Windows) [英] Gem installation error: You have to install development tools first (Windows)

查看:11
本文介绍了GEM安装错误:您必须先安装开发工具(Windows)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试安装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:Ruby193lib ubygems1.9.1gems hin-1.6.3ext hin_parser中的mkmf文件的外观:

"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。

为什么我收到该错误?有一行声明"无法创建Makefile...",但这与此相关吗?

推荐答案

如果您的系统上尚未安装Xcode开发工具(可能您最近升级了操作系统或Xcode),请运行xcode-select --install

否则,更具侵入性的修复方法是使用--switch标志

设置活动目录

sudo xcode-select --switch /

从Xcode-选择手册:

  -s <path>, --switch <path>
          Sets the active developer directory to the given path, for example
          /Applications/Xcode-beta.app. This command must be run with
          superuser permissions (see sudo(8)), and will affect all users on
          the system. To set the path without superuser permissions or only
          for the current shell session, use the DEVELOPER_DIR environment
          variable instead (see ENVIRONMENT).

这篇关于GEM安装错误:您必须先安装开发工具(Windows)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆