I'm trying to install the Bson Gem in a rails application (bson version 2.3.0) on Windows by running gem install bson -v '2.3.0 (as instructed to do so by bundle install), but the installation fails everytime with the same error report:
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
Running ruby --version outputs ruby 2.0.0p481 (2014-05-08) [i386-mingw32]
It is a bug: cross-compiling ruby_2_0_0 to Windows is failing (rb_w32_pow). You can see it:
https://www.ruby-forum.com/topic/4411245
To solve the question, you could just add the definition of _PC_64 and _MCW_PC manually. The original definition for these value lies in file _mingw_float.h ( but i can not find it)
So, you can just modified
d:/Tools/Ruby/currentVersion/include/ruby-2.0.0/ruby/win32.h
(File which the error occurs) by adding definition of these values. For me,
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;
}
You also can see the link: https://github.com/mongoid/mongoid/issues/3489#issuecomment-34218208
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With