Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ruby-on-rails/66.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby on rails 为bson Gem构建本机扩展失败_Ruby On Rails_Ruby_Windows - Fatal编程技术网

Ruby on rails 为bson Gem构建本机扩展失败

Ruby on rails 为bson Gem构建本机扩展失败,ruby-on-rails,ruby,windows,Ruby On Rails,Ruby,Windows,我正试图通过运行Gem install Bson-v'2.3.0(按照bundle install的指示)在Windows上的rails应用程序(Bson版本2.3.0)中安装Bson Gem,但每次安装都失败,并显示相同的错误报告: Building native extensions. This could take a while... ERROR: Error installing bson: ERROR: Failed to build gem native ext

我正试图通过运行
Gem install Bson-v'2.3.0
(按照
bundle install
的指示)在Windows上的rails应用程序(Bson版本2.3.0)中安装Bson Gem,但每次安装都失败,并显示相同的错误报告:

Building native extensions.  This could take a while...
ERROR:  Error installing bson:
        ERROR: Failed to build gem native extension.

    D:/Tools/Ruby/currentVersion/bin/ruby.exe extconf.rb
creating Makefile

make "DESTDIR=" clean

make "DESTDIR="
generating native-i386-mingw32.def
compiling native.c
In file included from d:/Tools/Ruby/currentVersion/include/ruby-2.0.0/ruby/defin
es.h:153:0,
                 from d:/Tools/Ruby/currentVersion/include/ruby-2.0.0/ruby/ruby.
h:70,
                 from d:/Tools/Ruby/currentVersion/include/ruby-2.0.0/ruby.h:33,

                 from native.c:26:
d:/Tools/Ruby/currentVersion/include/ruby-2.0.0/ruby/win32.h: In function 'rb_w3
2_pow':
d:/Tools/Ruby/currentVersion/include/ruby-2.0.0/ruby/win32.h:801:5: warning: imp
licit declaration of function '_controlfp' [-Wimplicit-function-declaration]
     unsigned int default_control = _controlfp(0, 0);
     ^
d:/Tools/Ruby/currentVersion/include/ruby-2.0.0/ruby/win32.h:802:16: error: '_PC
_64' undeclared (first use in this function)
     _controlfp(_PC_64, _MCW_PC);
                ^
d:/Tools/Ruby/currentVersion/include/ruby-2.0.0/ruby/win32.h:802:16: note: each
undeclared identifier is reported only once for each function it appears in
d:/Tools/Ruby/currentVersion/include/ruby-2.0.0/ruby/win32.h:802:24: error: '_MC
W_PC' undeclared (first use in this function)
     _controlfp(_PC_64, _MCW_PC);
                        ^
make: *** [native.o] Error 1

make failed, exit code 2

Gem files will remain installed in D:/Tools/Ruby/currentVersion/lib/ruby/gems/2.
0.0/gems/bson-2.3.0 for inspection.
Results logged to D:/Tools/Ruby/currentVersion/lib/ruby/gems/2.0.0/extensions/x8
6-mingw32/2.0.0/bson-2.3.0/gem_make.out

运行
ruby--version
输出
ruby 2.0.0p481(2014-05-08)[i386-mingw32]
这是一个错误:将ruby\u 2\u 0\u 0交叉编译到Windows失败(rb\u w32\u pow)。 你可以看到:

要解决这个问题,您可以手动添加_PC_64和_MCW_PC的定义。这些值的原始定义位于文件_mingw_float.h中(但我找不到它)

所以,你可以修改一下

d:/Tools/Ruby/currentVersion/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;
}
您还可以看到以下链接: