gem install mongoid --platform = ruby​​无法构建gem原生扩展

时间:2014-08-06 14:47:59

标签: ruby windows-7 gem installation

我正在使用Windows 7,当我尝试安装mongoid时我有这个问题这是日志

C:/Ruby200/bin/ruby.exe -r ./siteconf20140806-7376-tm3b3l.rb extconf.rb
creating Makefile

make "DESTDIR=" clean

make "DESTDIR="
generating native-i386-mingw32.def
compiling native.c
In file included from c:/Ruby200/include/ruby-2.0.0/ruby/defines.h:153:0,
             from c:/Ruby200/include/ruby-2.0.0/ruby/ruby.h:70,
             from c:/Ruby200/include/ruby-2.0.0/ruby.h:33,
             from native.c:26:
c:/Ruby200/include/ruby-2.0.0/ruby/win32.h: In function 'rb_w32_pow':
c:/Ruby200/include/ruby-2.0.0/ruby/win32.h:801:5: warning: implicit declaration of
function '_controlfp' [-Wimplicit-function-declaration]
c:/Ruby200/include/ruby-2.0.0/ruby/win32.h:802:16: error: '_PC_64' undeclared (first
use in this function)
c:/Ruby200/include/ruby-2.0.0/ruby/win32.h:802:16: note: each undeclared identifier is 
reported only once for each function it appears in c:/Ruby200/include/ruby- 
2.0.0/ruby/win32.h:802:24: error: '_MCW_PC' undeclared (first use in this function)

make: *** [native.o] Error 1

make failed, exit code 2

我已经安装了devKit

1 个答案:

答案 0 :(得分:3)

我遇到了同样的问题,这个链接https://github.com/mongoid/mongoid/issues/3489帮助我解决了问题。

首先,转到你的... \ Ruby200 \ include \ ruby​​-2.0.0 \ ruby​​目录并找到win32.h文件。 然后通过添加缺少的变量来修改文件:

...
...
static inline double
rb_w32_pow(double x, double y)
{
    return powl(x, y);
}
#elif defined(__MINGW64_VERSION_MAJOR)

#ifndef _PC_64
#define _PC_64 0x00000000
#endif

#ifndef _MCW_PC
#define _MCW_PC 0x00030000
#endif

/*
 * Set floating point precision for pow() of mingw-w64 x86.
 * With default precision the result is not proper on WinXP.
 */
static inline double
rb_w32_pow(double x, double y)
{
    double r;
    unsigned int default_control = _controlfp(0, 0);
    _controlfp(_PC_64, _MCW_PC);
    r = pow(x, y);
    /* Restore setting */
    _controlfp(default_control, _MCW_PC);
    return r;
}
...
...

希望它也适合你!祝你好运!