我试图通过运行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_2_0_0到Windows失败(rb_w32_pow)。 你可以看到:
https://www.ruby-forum.com/topic/4411245
为了解决这个问题,你可以手动添加_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; }
你也可以看到链接: https : //github.com/mongoid/mongoid/issues/3489#issuecomment-34218208