sakhri Mohamed Amine
sakhri Mohamed Amine

Reputation: 11

gem install mongoid --platform=ruby failed to build gem native extension

i 'm using windows 7 and when i try to install mongoid i have this problem this is the log

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

i have installed devKit

Upvotes: 1

Views: 331

Answers (1)

NotANumber
NotANumber

Reputation: 301

I just had the same issues and this link https://github.com/mongoid/mongoid/issues/3489 helped me solve the problem.

So first, go to your ...\Ruby200\include\ruby-2.0.0\ruby directory and locate win32.h file. Then modify the file by adding the missing variables:

...
...
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;
}
...
...

Hope it works for you as well! Good luck!

Upvotes: 3

Related Questions