Building native extensions fails for bson Gem - ruby-on-rails

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

Related

gem not installing unde Monterey OS X

A rails application created with Ruby 3.1.0 and rails 7.0.3 on a Mac OS X 10.13.6 bundles all required gems using Bundler version 2.3.3
When migrating the application to Mac OS X 12.3 (monterey) with the same bundler version,
this is encountered:
An error occurred while installing semacode-ruby19 (0.7.4), and Bundler cannot continue.
Commenting out the gem allows the gem intallation procedure to complete. However the application remains incomplete, test/test_helper.rb for example needs to be commented out as the application tests the generation of Barby::DataMatrix.new(...)
The aforementioned gem has not been updated in a long time (thus no expectations should be entertained) - however the functionality of encoding DataMatrix for ruby remains a going concern. What options are open at this point?
I remain uncertain as to the source of the problem - the ∆s are OS X and homebrew - and thus uncertain as to where to report this. Suggestions welcome.
Update
As per the suggestion, the manual installation of the gem also fails:
gem install semacode -v 0.7.4 -- --with-cflags="-Wno-error=implicit-function-declaration"
Fetching semacode-0.7.4.gem
Building native extensions with: '--with-cflags=-Wno-error=implicit-function-declaration'
This could take a while...
ERROR: Error installing semacode:
ERROR: Failed to build gem native extension.
current directory: /Users/deploy/.rbenv/versions/3.1.0/lib/ruby/gems/3.1.0/gems/semacode-0.7.4/ext
/Users/deploy/.rbenv/versions/3.1.0/bin/ruby -I /Users/deploy/.rbenv/versions/3.1.0/lib/ruby/3.1.0 -r ./siteconf20220830-40292-dndt8s.rb extconf.rb --with-cflags\=-Wno-error\=implicit-function-declaration
creating Makefile
current directory: /Users/deploy/.rbenv/versions/3.1.0/lib/ruby/gems/3.1.0/gems/semacode-0.7.4/ext
make DESTDIR\= clean
current directory: /Users/deploy/.rbenv/versions/3.1.0/lib/ruby/gems/3.1.0/gems/semacode-0.7.4/ext
make DESTDIR\=
compiling iec16022ecc200.c
iec16022ecc200.c:284:80: warning: data argument not used by format string [-Wformat-extra-args]
rb_raise(rb_eArgError, "cannot encode character in X12", c);
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^
iec16022ecc200.c:299:80: warning: data argument not used by format string [-Wformat-extra-args]
rb_raise(rb_eArgError, "cannot encode character in X12", c);
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^
iec16022ecc200.c:323:89: warning: data argument not used by format string [-Wformat-extra-args]
rb_raise(rb_eRuntimeError, "this should not be happening!", c);
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^
iec16022ecc200.c:498:9: warning: incompatible pointer to integer conversion initializing 'VALUE' (aka 'unsigned long') with an expression of type 'void *' [-Wint-conversion]
VALUE rb_str = NULL;
^ ~~~~
iec16022ecc200.c:908:12: warning: assigning to 'unsigned char *' from 'char *' converts between pointers to integer types where one is of the unique plain 'char' type and the other is not [-Wpointer-sign]
grid = ALLOC_N(char, W * H);
^ ~~~~~~~~~~~~~~~~~~~~
5 warnings generated.
compiling reedsol.c
compiling semacode.c
semacode.c:61:3: warning: implicit declaration of function 'iec16022init' is invalid in C99 [-Wimplicit-function-declaration]
iec16022init(&semacode->width, &semacode->height, message);
^
semacode.c:96:28: warning: 'bzero' call operates on objects of type 'semacode_t' (aka 'struct semacode_t') while the size is based on a different type 'semacode_t *' (aka 'struct semacode_t *') [-Wsizeof-pointer-memaccess]
bzero(semacode, sizeof(semacode));
~~~~~~~~ ^~~~~~~~
semacode.c:96:28: note: did you mean to dereference the argument to 'sizeof' (and multiply it by the number of elements)?
bzero(semacode, sizeof(semacode));
^~~~~~~~
semacode.c:129:27: error: no member named 'len' in 'struct RString'
encode_string(semacode, StringValueLen(message), StringValuePtr(message));
^~~~~~~~~~~~~~~~~~~~~~~
./semacode.h:26:56: note: expanded from macro 'StringValueLen'
#define StringValueLen(s) RSTRING(RB_STRING_VALUE(s))->len
~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^
semacode.c:239:20: warning: equality comparison result unused [-Wunused-comparison]
semacode->data == NULL;
~~~~~~~~~~~~~~~^~~~~~~
semacode.c:239:20: note: use '=' to turn this equality comparison into an assignment
semacode->data == NULL;
^~
=
semacode.c:243:44: error: no member named 'len' in 'struct RString'
DATA_PTR(self) = encode_string(semacode, StringValueLen(message), StringValuePtr(message));
^~~~~~~~~~~~~~~~~~~~~~~
./semacode.h:26:56: note: expanded from macro 'StringValueLen'
#define StringValueLen(s) RSTRING(RB_STRING_VALUE(s))->len
~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^
3 warnings and 2 errors generated.
make: *** [semacode.o] Error 1
make failed, exit code 2
Gem files will remain installed in /Users/deploy/.rbenv/versions/3.1.0/lib/ruby/gems/3.1.0/gems/semacode-0.7.4 for inspection.
Results logged to /Users/deploy/.rbenv/versions/3.1.0/lib/ruby/gems/3.1.0/extensions/arm64-darwin-21/3.1.0/semacode-0.7.4/gem_make.out

OpenCV 3.4.4 make error with mingw32-make "persistence.cpp"

I am currently installing OpenCV3.4.4 in ordre to use it with Code::Blocks. I used CMake GUI to Configure and Generates the binaries.
But when I'm using 'mingw32-make' to finish the installation, an error occurs about strnlen which apparently is not define. I have the following message :
"
C:\opencv\sources\modules\core\src\persistence.cpp: In function 'char* icvGets(CvFileStorage*, char*, int)':
C:\opencv\sources\modules\core\src\persistence.cpp:71:46: error: 'strnlen' was not declared in this scope
size_t sz = strnlen(ptr, maxCount);
^
C:\opencv\sources\modules\core\src\persistence.cpp:82:46: error: 'strnlen' was not declared in this scope
size_t sz = strnlen(ptr, maxCount);
^
modules\core\CMakeFiles\opencv_core.dir\build.make:901: recipe for target 'modules/core/CMakeFiles/opencv_core.dir/src/persistence.cpp.obj' failed
mingw32-make[2]: * [modules/core/CMakeFiles/opencv_core.dir/src/persistence.cpp.obj] Error 1
CMakeFiles\Makefile2:1671: recipe for target 'modules/core/CMakeFiles/opencv_core.dir/all' failed
mingw32-make[1]: * [modules/core/CMakeFiles/opencv_core.dir/all] Error 2
Makefile:161: recipe for target 'all' failed
mingw32-make: *** [all] Error 2"
"
I've read some other forum asking to change some variables in CMake GUI but for other issues and I did not succeed to find the same as me. I hope that someone could help me. thank you
If this is useful for you, I was able to compile OpenCV 3.1.0 with MinGW32.
I have not been able to compile OpenCV3.4.7 with MinGW32 (I think that this backward compatibility has been abandoned), but I succeeded to compile OpenCV3.4.7 with MinGW64.

An error occurred while installing puma (2.11.1), and Bundler cannot continue

After running bundle install --path vendor it's showing following error. I'm using macOS Sierra. This problem occurred after update homebrew. I've uninstalled currently installed puma from my gem list. But the same problem occurred here.
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
/Users/tanvirhasan/.rbenv/versions/2.2.0/bin/ruby -r ./siteconf20161114-22170-lrj70g.rb extconf.rb
checking for BIO_read() in -lcrypto... yes
checking for SSL_CTX_new() in -lssl... yes
creating Makefile
make "DESTDIR=" clean
make "DESTDIR="
compiling http11_parser.c
compiling io_buffer.c
io_buffer.c:119:10: warning: passing 'uint8_t *' (aka 'unsigned char *') to parameter of type 'const char *' converts between pointers to integer types with different sign [-Wpointer-sign]
return rb_str_new(b->top, b->cur - b->top);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/tanvirhasan/.rbenv/versions/2.2.0/include/ruby-2.2.0/ruby/intern.h:796:20: note: expanded from macro 'rb_str_new'
rb_str_new_static((str), (len)) : \
^~~~~
/Users/tanvirhasan/.rbenv/versions/2.2.0/include/ruby-2.2.0/ruby/intern.h:727:37: note: passing argument to parameter here
VALUE rb_str_new_static(const char *, long);
^
io_buffer.c:119:10: warning: passing 'uint8_t *' (aka 'unsigned char *') to parameter of type 'const char *' converts between pointers to integer types with different sign [-Wpointer-sign]
return rb_str_new(b->top, b->cur - b->top);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/tanvirhasan/.rbenv/versions/2.2.0/include/ruby-2.2.0/ruby/intern.h:797:13: note: expanded from macro 'rb_str_new'
rb_str_new((str), (len)); \
^~~~~
/Users/tanvirhasan/.rbenv/versions/2.2.0/include/ruby-2.2.0/ruby/intern.h:706:29: note: passing argument to parameter here
VALUE rb_str_new(const char*, long);
^
2 warnings generated.
compiling mini_ssl.c
In file included from mini_ssl.c:3:
/Users/tanvirhasan/.rbenv/versions/2.2.0/include/ruby-2.2.0/ruby/backward/rubyio.h:2:2: warning: use "ruby/io.h" instead of "rubyio.h" [-W#warnings]
#warning use "ruby/io.h" instead of "rubyio.h"
^
mini_ssl.c:4:10: fatal error: 'openssl/bio.h' file not found
#include <openssl/bio.h>
^
1 warning and 1 error generated.
make: *** [mini_ssl.o] Error 1
make failed, exit code 2
Gem files will remain installed in /Users/tanvirhasan/Git/Nascenia/cribber-web/vendor/ruby/2.2.0/gems/puma-2.11.1 for inspection.
Results logged to /Users/tanvirhasan/Git/Nascenia/cribber-web/vendor/ruby/2.2.0/extensions/x86_64-darwin-15/2.2.0-static/puma-2.11.1/gem_make.out
You updated homebrew, but you probably didn't update XCode. Pull up an instance of Terminal and run:
brew doctor
Homebrew will probably warn you about one or more libraries that need to be updated, including XCode.
Run:
xcode-select --install
Make sure you accept the license for the new version of XCode by running:
sudo xcodebuild -license

Can't build eventmachine 1.0.3 Mac OS X 10.9.2

I want to reinstall my ruby on rails environment, but it failed.
I work on Mac OS X 10.9.2, using Ruby 2.1.2, Apple LLVM version 5.1 (clang-503.0.40)
I want to run:
gem install eventmachine -v '1.0.3'
But I get:
Building native extensions. This could take a while...
ERROR: Error installing eventmachine:
ERROR: Failed to build gem native extension.
/Users/nm/.rbenv/versions/2.1.2/bin/ruby extconf.rb
checking for rb_trap_immediate in ruby.h,rubysig.h... no
checking for rb_thread_blocking_region()... yes
checking for inotify_init() in sys/inotify.h... no
checking for __NR_inotify_init in sys/syscall.h... no
checking for writev() in sys/uio.h... yes
checking for rb_wait_for_single_fd()... yes
checking for rb_enable_interrupt()... no
checking for rb_time_new()... yes
checking for sys/event.h... yes
checking for sys/queue.h... yes
creating Makefile
make "DESTDIR=" clean
make "DESTDIR="
compiling binder.cpp
compiling cmain.cpp
compiling ed.cpp
ed.cpp:987:18: warning: variable length arrays are a C99 feature [-Wvla-extension]
struct iovec iov[ iovcnt ];
^
1 warning generated.
compiling em.cpp
em.cpp:75:2: warning: field 'LoopBreakerWriter' will be initialized after field 'NumCloseScheduled' [-Wreorder]
LoopBreakerWriter (-1),
^
em.cpp:822:2: warning: 'rb_thread_blocking_region' is deprecated [-Wdeprecated-declarations]
rb_thread_blocking_region (_SelectDataSelect, (void*)this, RUBY_UBF_IO, 0);
^
/Users/nm/.rbenv/versions/2.1.2/include/ruby-2.1.0/ruby/intern.h:870:18: note: 'rb_thread_blocking_region' declared here
DEPRECATED(VALUE rb_thread_blocking_region(rb_blocking_function_t *func, void *data1,
^
/Users/nm/.rbenv/versions/2.1.2/include/ruby-2.1.0/x86_64-darwin13.0/ruby/config.h:114:52: note: expanded from macro 'DEPRECATED'
#define DEPRECATED(x) __attribute__ ((deprecated)) x
^
em.cpp:946:6: warning: 'rb_thread_select' is deprecated [-Wdeprecated-declarations]
EmSelect (0, NULL, NULL, NULL, &tv);
^
./em.h:25:20: note: expanded from macro 'EmSelect'
#define EmSelect rb_thread_select
^
/Users/nm/.rbenv/versions/2.1.2/include/ruby-2.1.0/ruby/intern.h:440:16: note: 'rb_thread_select' declared here
DEPRECATED(int rb_thread_select(int, fd_set *, fd_set *, fd_set *, struct timeval *));
^
/Users/nm/.rbenv/versions/2.1.2/include/ruby-2.1.0/x86_64-darwin13.0/ruby/config.h:114:52: note: expanded from macro 'DEPRECATED'
#define DEPRECATED(x) __attribute__ ((deprecated)) x
^
em.cpp:1109:40: error: invalid operands to binary expression ('__bind<int &, sockaddr *&, int &>' and 'int')
if (bind (sd, bind_to, bind_to_size) < 0) {
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^ ~
em.cpp:1522:6: error: value of type '__bind<int &, sockaddr *&, int &>' is not contextually convertible to 'bool'
if (bind (sd_accept, bind_here, bind_size)) {
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
em.cpp:1600:53: error: invalid operands to binary expression ('__bind<int &, sockaddr *, unsigned long>' and 'int')
if (bind (sd, (struct sockaddr*)&sin, sizeof(sin)) != 0)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^ ~
em.cpp:1869:6: error: value of type '__bind<int &, sockaddr *, unsigned long>' is not contextually convertible to 'bool'
if (bind (sd_accept, (struct sockaddr*)&s_sun, sizeof(s_sun))) {
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from em.cpp:23:
In file included from ./project.h:150:
./em.h:189:12: warning: private field 'NextHeartbeatTime' is not used [-Wunused-private-field]
uint64_t NextHeartbeatTime;
^
./em.h:221:22: warning: private field 'inotify' is not used [-Wunused-private-field]
InotifyDescriptor *inotify; // pollable descriptor for our inotify instance
^
5 warnings and 4 errors generated.
make: *** [em.o] Error 1
make failed, exit code 2
Gem files will remain installed in /Users/nm/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/eventmachine-1.0.3 for inspection.
Results logged to /Users/nm/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/extensions/x86_64-darwin-13/2.1.0-static/eventmachine-1.0.3/gem_make.out
When I install version 1.0.1 or 1.0.2, I will get some similar errors.
Someone can tell me why? thanks.
From the docs it looks like eventmachine does not yet support Ruby 2+
EventMachine supports Ruby 1.8.7, 1.9.2, REE, JRuby and works well on
Windows as well as many operating systems from the Unix family (Linux,
Mac OS X, BSD flavors).

Ruby on Rails - Error installing bdb. Failed to build gem native extension

When running gem install bdb I get the following error:
Error installing bdb:
ERROR: Failed to build gem native extension.
Anyone know where I can find the bdb library for Mac OS X?
Full error:
Building native extensions. This could take a while...
ERROR: Error installing bdb:
ERROR: Failed to build gem native extension.
...
checking for db_version() in -ldb-5.1... yes
Writing bdb_aux._c (defines), this takes a while
don't know how to handle DB_DEGREE_2 DB_READ_COMMITTED, guessing UINT
don't know how to handle DB_DIRTY_READ DB_READ_UNCOMMITTED, guessing UINT
don't know how to handle DB_HEAP_RID_SZ (sizeof(db_pgno_t) + sizeof(db_indx_t)), guessing UINT
wrote 491 defines
creating Makefile
make
...
bdb.c:84:1: warning: "eDbE_create" redefined
bdb.c:50:1: warning: this is the location of the previous definition
bdb.c: In function ‘assoc_rescue’:
bdb.c:1200: warning: format not a string literal and no format arguments
bdb.c: In function ‘assoc_callback’:
bdb.c:1248: warning: comparison between signed and unsigned
bdb.c:1249: warning: pointer of type ‘void *’ used in arithmetic
bdb.c: In function ‘env_set_cachesize’:
bdb.c:1830: warning: implicit conversion shortens 64-bit value into a 32-bit value
bdb.c:1831: warning: implicit conversion shortens 64-bit value into a 32-bit value
bdb.c: In function ‘env_txn_stat’:
bdb.c:2299: warning: comparison between signed and unsigned
bdb.c: In function ‘env_repmgr_set_local_site’:
bdb.c:3005: error: ‘DB_ENV’ has no member named ‘repmgr_set_local_site’
bdb.c: In function ‘env_repmgr_add_remote_site’:
bdb.c:3024: error: ‘DB_ENV’ has no member named ‘repmgr_add_remote_site’
bdb.c:3331:1: warning: "eDbE_create" redefined
bdb.c:84:1: warning: this is the location of the previous definition
bdb.c:3424:1: warning: "ENV_LOG_CONFIG_FUNC" redefined
bdb.c:2533:1: warning: this is the location of the previous definition
make: *** [bdb.o] Error 1
Did you see the instructions on the bdb page?
As a Gem
At the moment this library is not available on RubyForge. To install
it as a gem, do the following:
[sudo] gem install bdb
For Berkeley DB v4.7 installed from MacPorts do
the following:
[sudo] env ARCHFLAGS="-arch i386" gem install bdb This assumes you're
on OS X and BerkeleyDB wasn't compiled as a universal binary.
So it looks like you need to install berkeley db via macports/brew to get the Gem to install.

Resources