【问题标题】:gem install mongoid --platform=ruby failed to build gem native extensiongem install mongoid --platform=ruby 无法构建 gem 原生扩展
【发布时间】:2014-08-06 14:47:59
【问题描述】:

我正在使用 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

【问题讨论】:

标签: ruby windows-7 gem installation


【解决方案1】:

我也遇到了同样的问题,这个链接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;
}
...
...

希望它也适用于您!祝你好运!

【讨论】:

    猜你喜欢
    • 2013-06-27
    • 2011-05-27
    • 2010-09-07
    • 2021-01-12
    • 1970-01-01
    • 2015-07-20
    • 2015-06-18
    • 2011-05-17
    相关资源
    最近更新 更多