安装gsl gem的问题

我可以在我的主目录中成功安装gsl库,但是当我尝试安装gsl gem时,我得到了一个我不理解的大错误列表。 我想知道是否有人可以告诉我为什么我会得到这些错误。 我可以说我有:

成功安装gsl; 至少那是它的样子。 我指出了gsl-config的路径

这是错误日志的样子:

Building native extensions. This could take a while... ERROR: Error installing gsl: ERROR: Failed to build gem native extension. /home/ted/ruby-1.9.1/bin/ruby extconf.rb install gsl checking gsl version... 1.15 checking gsl cflags... -I/home/ted/gsl-1.15/include checking for main() in -lcblas... no checking gsl libs... -L/home/ted/gsl-1.15/lib -lgsl -lgslcblas -lm checking for round()... no checking for rngextra/rngextra.h... no checking for qrngextra/qrngextra.h... no checking for ool/ool_version.h... no checking for tensor/tensor.h... no checking for jacobi.h... no checking for gsl/gsl_cqp.h... no checking for gsl/gsl_multimin_fsdf.h... no checking for gsl_poly_solve_quartic() in -lgsl... no checking for gsl_eigen_francis() in -lgsl... no checking for ndlinear/gsl_multifit_ndlinear.h... no checking for alf/alf.h... no checking rb-gsl version...1.14.7 checking ruby version... 1.9.1 checking for graph... no checking for narray.h... yes checking for tamu_anova/tamu_anova.h... no checking for main() in -ltamuanova... no creating Makefile make gcc -I. -I/home/ted/ruby-1.9.1/include/ruby-1.9.1/x86_64-linux -I/home/ted/ruby-1.9.1/include/ruby-1.9.1/ruby/backward -I/home/ted/ruby-1.9.1/include/ruby-1.9.1 -I. -DHAVE_NARRAY_H -I/home/ted/ruby-1.9.1/lib/ruby/gems/1.9.1/gems/narray-0.6.0.1/. -I/home/ted/ruby-1.9.1/lib/ruby/site_ruby/1.9.1/x86_64-linux -fPIC -Wall -I../include -I/home/ted/gsl-1.15/include -o sf_bessel.o -c sf_bessel.c In file included from sf_bessel.c:13: ../include/rb_gsl_sf.h:15:24: error: gsl/gsl_sf.h: No such file or directory ../include/rb_gsl_sf.h:16:27: error: gsl/gsl_errno.h: No such file or directory ../include/rb_gsl_sf.h:17:28: error: gsl/gsl_vector.h: No such file or directory In file included from ../include/rb_gsl_sf.h:18, from sf_bessel.c:13: /home/ted/gsl-1.15/include/gsl/gsl_math.h:23:25: error: gsl/gsl_sys.h: No such file or directory In file included from sf_bessel.c:13: ../include/rb_gsl_sf.h:19:29: error: gsl/gsl_complex.h: No such file or directory In file included from ../include/rb_gsl.h:20, from ../include/rb_gsl_sf.h:21, from sf_bessel.c:13: ../include/rb_gsl_common.h:23:28: error: gsl/gsl_matrix.h: No such file or directory ../include/rb_gsl_common.h:24:33: error: gsl/gsl_permutation.h: No such file or directory ../include/rb_gsl_common.h:25:32: error: gsl/gsl_ieee_utils.h: No such file or directory In file included from ../include/rb_gsl.h:20, from ../include/rb_gsl_sf.h:21, from sf_bessel.c:13: ../include/rb_gsl_common.h:322: warning: type defaults to ‘int’ in declaration of ‘gsl_complex’ ../include/rb_gsl_common.h:322: error: expected ‘;’, ‘,’ or ‘)’ before ‘*’ token ../include/rb_gsl_common.h:324: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘*’ token ../include/rb_gsl_common.h:325: error: expected ‘)’ before ‘*’ token ../include/rb_gsl_common.h:326: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘*’ token ../include/rb_gsl_common.h:328: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘*’ token ../include/rb_gsl_common.h:329: error: expected ‘)’ before ‘*’ token ../include/rb_gsl_common.h:330: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘*’ token ../include/rb_gsl_common.h:340: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘ary2complex’ In file included from ../include/rb_gsl.h:21, from ../include/rb_gsl_sf.h:21, from sf_bessel.c:13: ../include/rb_gsl_math.h:24: error: expected ‘)’ before ‘(’ token In file included from ../include/rb_gsl.h:22, from ../include/rb_gsl_sf.h:21, from sf_bessel.c:13: ../include/rb_gsl_complex.h:19:34: error: gsl/gsl_complex_math.h: No such file or directory 

  sf_bessel.c: In function ‘rb_gsl_sf_bessel_zero_J1_e’: sf_bessel.c:643: error: ‘gsl_sf_bessel_zero_J1_e’ undeclared (first use in this function) sf_bessel.c: In function ‘rb_gsl_sf_bessel_zero_Jnu’: sf_bessel.c:648: error: ‘gsl_sf_bessel_zero_Jnu’ undeclared (first use in this function) sf_bessel.c: In function ‘rb_gsl_sf_bessel_zero_Jnu_e’: sf_bessel.c:653: error: ‘gsl_sf_bessel_zero_Jnu_e’ undeclared (first use in this function) make: *** [sf_bessel.o] Error 1 Gem files will remain installed in /home/ted/ruby-1.9.1/lib/ruby/gems/1.9.1/gems/gsl-1.14.7 for inspection. Results logged to /home/ted/ruby-1.9.1/lib/ruby/gems/1.9.1/gems/gsl-1.14.7/ext/gem_make.out 

安装ruby GSL:

Ubuntu 11.10包含一个与ruby / gsl不兼容的libgsl0的更新版本(1.15)

必须安装旧版本1.14 for ruby​​ / gsl才能工作:

 curl -O http://mirror.veriportal.com/gnu/gsl/gsl-1.14.tar.gz tar xvzf gsl-1.14.tar.gz cd gsl-1.14 ./configure make sudo make install sudo gem install --conservative --no-ri --no-rdoc gsl 

安装工作正常并在Ubuntu和Debian Squeeze上进行测试:

 Fetching: narray-0.6.0.1.gem (100%) Building native extensions. This could take a while... Fetching: gsl-1.14.7.gem (100%) Building native extensions. This could take a while... Successfully installed narray-0.6.0.1 Successfully installed gsl-1.14.7 2 gems installed 

你在哪个操作系统?

首先,您需要在您的操作系统上以root身份安装gslgsl-devel RPM …例如在Fedora Linux上:

 sudo yum install -y gsl gsl-devel 

然后执行gem install gslbundle install

如果没有gsl-devel包,它将找不到正确的C-header文件。

您还需要确保这些头文件安装在LD_LIBRARY_PATH中包含的位置,或者在/etc/ld.so.conf中列出

如果你有:

  • GSL 1.16 (使用gsl-config --version检查)(例如在Ubuntu 14.04中 ),
  • Ruby 2.1

然后尝试https://github.com/siefca/rb-gsl – 它已针对此类配置进行了调整。
它也适用于Ruby 1.9和Ruby 2.0。

如果您使用bundler来管理项目中的gem,那么在Gemfile

 gem 'gsl', :git => 'git://github.com/siefca/rb-gsl' 

干杯!

对于仍然在努力使用gsl_matrix_complex_equal问题进行安装的人。

如果您已经运行brew install gsl ,将在撰写本文时安装1.15,然后尝试安装ruby绑定,您可能会遇到此问题。

使用此repo作为您的rb-gsl gem源解决了这个问题: https : //github.com/30robots/rb-gsl

但是,如果你有一个更新版本的rubygems,那个repo会调用Gem#searcher ,这是一个已弃用且现已删除的方法。

我的repo更新调用使用Gem::Specification API:

https://github.com/whistlerbrk/rb-gsl

简而言之:

在OSX上brew install gsl

在你的Gemfile中:

gem 'gsl', :git => 'git://github.com/whistlerbrk/rb-gsl.git'

在ubuntu 13.04下,这解决了这个问题:

sudo apt-get install libgsl0-dev

无需手动安装旧版本

注意它似乎不适用于Ruby 2.1.0。

对于Ubuntu 12.04 LTS和Ruby 2.0.0:

 cd ~ wget ftp://ftp.gnu.org/gnu/gsl/gsl-1.15.tar.gz tar xvzf gsl-1.15.tar.gz cd gsl-1.15 ./configure make sudo make install 

检查GSL 1.15是否安装正确

 gsl-config --version 

然后安装gem(gsl 1.15.3)

 gem install gsl 

在我全新安装的Mac OS X Yosemite上 ,我特别需要1.15.3,而自制软件对我来说无法获得(没有brew install gsl115

 curl ftp://ftp.gnu.org/gnu/gsl/gsl-1.15.tar.gz > gsl-1.15.tar.gz tar xvzf gsl-1.15.tar.gz cd gsl-1.15 ./configure make sudo make install gem install gsl 

对于ubuntu 13.10,ruby 2.0.0可以正常工作 –

 curl -O http://ftp.unicamp.br/pub/gnu/gsl/gsl-1.16.tar.gz tar xvzf gsl-1.16.tar.gz cd gsl-1.16 ./configure make sudo make install sudo gem install --conservative --no-ri --no-rdoc gsl 

注意:Ami Navon写道 –

必须安装旧版本1.14才能使用ruby / gsl

现在gsl-1.16 / ruby​​-2.0.0并不现实

lsb_release -a Ubuntu 14.04.1 LTS
ruby --version ruby 2.1.2p95


重要:安装gsl开发包https://askubuntu.com/a/490475/121418
sudo apt-get install libgsl0-dev

在Gemfile中添加此行
gem 'rb-gsl'

通过终端安装gem
bundle install


校验
bundle show rb-gsl
/.rvm/gems/ruby-2.1.2/gems/rb-gsl-1.16.0.4

gsl-config --version
1.15


如有必要,请在ruby文件中使用require "gsl"

这也适用于ubuntu 16.04 LTS和ruby 2.2.2
sudo apt-get install libgsl0-dev