installing R gsl package on Mac

自古美人都是妖i 提交于 2019-12-04 23:49:01

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.

The following:

CFLAGS="-I/usr/local/opt/gsl/include" LDFLAGS="-L/usr/local/opt/gsl/lib -lgsl -lgslcblas" R
...
> install.packages("gsl")

worked for me.

Note that gsl-config lists the direct path to my Cellar, the paths above are brew symlinks.

I finally got this to work though I'm not sure which parts of the following are absolutely essential. Here's a step-by-step list of instructions:

(steps in parentheses may be optional. Perhaps the whole thing works with homebrew)

  1. (download the latest version of the GSL from http://ftp.gnu.org/gnu/gsl/ (as of this writing the file to get is gsl-1.16.tar.gz))
  2. (open up a terminal window, untar the file, cd into the directory and then run ./configure, make and make install)
  3. download the sources to the R package from http://cran.r-project.org/web/packages/gsl/index.html
  4. open up a terminal window and run launchctl setenv PATH "/usr/local/bin:$PATH"
  5. in the same terminal window, build the R package (I couldn't get this to work from within R) by untar'ing the file just downloaded, cding into the directory and then running R CMD build ./gsl and R CMD INSTALL gsl_1.9-10.tar.gz

For Mac, just run:

brew install gsl

then install the package in r

I believe that others will find your steps successful and I think they do need to be done in that order. The build of gsl from source does need to be done after adding the homebrew default directory to the path. If you had used the binary, it was built on a CRAN machine that was able to find the (external) GSL package in the expected directy (which is not the default for homebreww installations. You might have succeeded with `install.packages('gsl_1.9-10.tar.gz', repo=NULL, type="source") if the source package were in your working directory (or add the full path/name as the first argument.) Just as with using Terminal, if you click-hold-drag a file to the R console, you will get a text entry of the full path/name.

gsl-config in included with the gsl-devel package, try installing that. After that it should work

On OS X Mavericks at least, after installing gsl via brew install gsl, the gsl-config --prefix yields /usr/local/Cellar/gsl/1.16. However, many applications/libraries like gsll for Common Lisp (in my case) expect /usr/local/Cellar/gsl/1.16/lib instead. In my case, the super lazy (long-term unacceptable) solution was just to symlink the libs from /usr/local/Cellar/gsl/1.16/lib into /usr/local/Cellar/gsl/1.16 and all was well. Hope this helps.

Note to self: On Debian, to fix

checking for gsl-config... no
configure: error: gsl-config not found, is GSL installed?

I needed to

sudo apt-get install libgsl-dev

Note that the package name on Debian is not gsl-devel as elsewhere. Sigh.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!