尝试获取bigdecimal 1.4.1。或 1.3.5 在 Rails 项目中编译。我得到:
bobwalsh@iMac2021 webservices % gem install bigdecimal -v '1.3.5'
Building native extensions. This could take a while...
ERROR: Error installing bigdecimal:
ERROR: Failed to build gem native extension.
current directory: /Users/bobwalsh/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/bigdecimal-1.3.5/ext/bigdecimal
/Users/bobwalsh/.rbenv/versions/3.1.2/bin/ruby -I /Users/bobwalsh/.rbenv/versions/3.1.2/lib/ruby/site_ruby/3.1.0 extconf.rb
checking for labs() in stdlib.h... yes
checking for llabs() in stdlib.h... yes
checking for finite() in math.h... yes
checking for isfinite() in math.h... no
checking for struct RRational in ruby.h... no
checking for rb_rational_num() in ruby.h... yes
checking for rb_rational_den() in ruby.h... yes
checking for rb_array_const_ptr() in ruby.h... yes
checking for rb_sym2str() in ruby.h... yes
creating Makefile
current directory: /Users/bobwalsh/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/bigdecimal-1.3.5/ext/bigdecimal
make DESTDIR\= sitearchdir\=./.gem.20221229-75388-86psx7 sitelibdir\=./.gem.20221229-75388-86psx7 clean
current directory: /Users/bobwalsh/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/bigdecimal-1.3.5/ext/bigdecimal
make DESTDIR\= sitearchdir\=./.gem.20221229-75388-86psx7 sitelibdir\=./.gem.20221229-75388-86psx7
compiling bigdecimal.c
bigdecimal.c:366:28: warning: implicit conversion loses integer precision: 'unsigned long' to 'int' [-Wshorten-64-to-32]
INT2NUM(p->MaxPrec*VpBaseFig()));
~~~~~~~ ~~~~~~~~~~^~~~~~~~~~~~
bigdecimal.c:365:39: warning: implicit conversion loses integer precision: 'unsigned long' to 'int' [-Wshorten-64-to-32]
obj = rb_assoc_new(INT2NUM(p->Prec*VpBaseFig()),
~~~~~~~ ~~~~~~~^~~~~~~~~~~~
bigdecimal.c:439:5: error: implicit declaration of function 'rb_check_safe_obj' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
rb_check_safe_obj(str);
^
bigdecimal.c:439:5: note: did you mean 'rb_check_safe_str'?
/Users/bobwalsh/.rbenv/versions/3.1.2/include/ruby-3.1.0/ruby/internal/core/rstring.h:383:6: note: 'rb_check_safe_str' declared here
void rb_check_safe_str(VALUE);
^
bigdecimal.c:2047:6: error: implicit declaration of function 'rb_check_safe_obj' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
rb_check_safe_obj(f);
^
bigdecimal.c:2152:30: warning: implicit conversion loses integer precision: 'ssize_t' (aka 'long') to 'int' [-Wshorten-64-to-32]
rb_ary_push(obj, INT2NUM(e));
~~~~~~~ ^
bigdecimal.c:2165:20: warning: implicit conversion loses integer precision: 'ssize_t' (aka 'long') to 'int' [-Wshorten-64-to-32]
return INT2NUM(e);
~~~~~~~ ^
bigdecimal.c:2737:27: warning: implicit conversion loses integer precision: 'size_t' (aka 'unsigned long') to 'int' [-Wshorten-64-to-32]
VALUE nCur = INT2NUM(VpGetPrecLimit());
~~~~~~~ ^~~~~~~~~~~~~~~~
5 warnings and 2 errors generated.
make: *** [bigdecimal.o] Error 1
make failed, exit code 2
Gem files will remain installed in /Users/bobwalsh/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/bigdecimal-1.3.5 for inspection.
Results logged to /Users/bobwalsh/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/extensions/x86_64-darwin-21/3.1.0/bigdecimal-1.3.5/gem_make.out
我该怎么做才能让它发挥作用?
尝试
gem install bigdecimal
,如果失败,请检查其错误日志。
通常你需要安装
ruby-dev
软件包,更多信息请参见 https://packages.debian.org/buster/ruby-dev
或
ruby-full
https://packages.debian.org/buster/ruby-full
要有大十进制。