在Mac上安装R gsl软件包 [英] installing R gsl package on Mac
问题描述
我正在尝试为R安装gsl
软件包,据我理解,这只是OSX Mavericks下GSL的包装.我已经尝试了显而易见的方法:
I'm trying to install the gsl
package for R, which I understand is simply a wrapper around the GSL, under OSX Mavericks. I've tried the obvious:
> install.packages('gsl')
Installing package into ‘/Users/myusername/Library/R/3.1/library’
(as ‘lib’ is unspecified)
package ‘gsl’ is available as a source package but not as a binary
Warning in install.packages :
package ‘gsl’ is not available (for R version 3.1.0)
所以我跑了
> install.packages('gsl',type = 'source')
Installing package into ‘/Users/myusername/Library/R/3.1/library’
(as ‘lib’ is unspecified)
trying URL 'http://cran.rstudio.com/src/contrib/gsl_1.9-10.tar.gz'
Content type 'application/x-gzip' length 342803 bytes (334 Kb)
opened URL
==================================================
downloaded 334 Kb
* installing *source* package ‘gsl’ ...
** package ‘gsl’ successfully unpacked and MD5 sums checked
checking for gsl-config... no
configure: error: gsl-config not found, is GSL installed?
ERROR: configuration failed for package ‘gsl’
* removing ‘/Users/myusername/Library/R/3.1/library/gsl’
Warning in install.packages :
installation of package ‘gsl’ had non-zero exit status
未安装GSL.天哪!所以我通过Homebrew安装GSL:
No GSL install. D'oh! So I install GSL via Homebrew:
~ brew install gsl
==> Downloading http://ftpmirror.gnu.org/gsl/gsl-1.15.tar.gz
######################################################################## 100.0%
==> ./configure --prefix=/usr/local/Cellar/gsl/1.15
==> make
==> make install
/usr/local/Cellar/gsl/1.15: 239 files, 6.7M, built in 101 seconds
尝试再次安装R软件包:
Try to install the R package again:
> install.packages('gsl',type = 'source')
Installing package into ‘/Users/myusername/Library/R/3.1/library’
(as ‘lib’ is unspecified)
trying URL 'http://cran.rstudio.com/src/contrib/gsl_1.9-10.tar.gz'
Content type 'application/x-gzip' length 342803 bytes (334 Kb)
opened URL
==================================================
downloaded 334 Kb
* installing *source* package ‘gsl’ ...
** package ‘gsl’ successfully unpacked and MD5 sums checked
checking for gsl-config... /usr/local/bin/gsl-config
checking if GSL version >= 1.12... checking for gcc... gcc
checking for C compiler default output file name... a.out
checking whether the C compiler works... yes
checking whether we are cross compiling... no
checking for suffix of executables...
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
configure: error: Need GSL version >= 1.12
ERROR: configuration failed for package ‘gsl’
* removing ‘/Users/myusername/Library/R/3.1/library/gsl’
Warning in install.packages :
installation of package ‘gsl’ had non-zero exit status
我显然会以错误的方式进行操作,但是不确定问题出在哪里.
I'm obviously going about this the wrong way but am unsure about where exactly the problem lies.
推荐答案
通过标准的brew安装,我可以使工作正常(OS X Yosemite 10.10,R 3.1.1,gsl 1.16,gsl R包1.9-10).通过分别用gsl-config --cflags
和gsl-config --libs
的输出手动在CFLAGS
和LDFLAGS
前面加上前缀,R和gsl.
I was able to get things working (OS X Yosemite 10.10, R 3.1.1, gsl 1.16, gsl R package 1.9-10) with standard brew-installed R and gsl by manually prefixing CFLAGS
and LDFLAGS
with the output from gsl-config --cflags
and gsl-config --libs
respectively.
以下:
CFLAGS="-I/usr/local/opt/gsl/include" LDFLAGS="-L/usr/local/opt/gsl/lib -lgsl -lgslcblas" R
...
> install.packages("gsl")
为我工作.
请注意,gsl-config
列出了通往我的酒窖的直接路径,上面的路径是Brew符号链接.
Note that gsl-config
lists the direct path to my Cellar, the paths above are brew symlinks.
这篇关于在Mac上安装R gsl软件包的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!