简体   繁体   中英

Installing Rmpfr in R 3.2.2 on Mac OS X (10.10.5 Yosemite)

I installed R on Mac OS using homebrew. Until now everything was smooth. Today, I wanted to use arbitrary precision on some calculations on R. I saw that Rmpfr package is easy to use, so I decided to install it. First, I used the usual:

install.packages("Rmpfr")

and I received this message:

checking for mpfr.h... no
configure: error: Header file mpfr.h not found; maybe use --with-mpfr-include=INCLUDE_PATH
ERROR: configuration failed for package ‘Rmpfr’

So I discovered that the mpfr headers were in /usr/local/Cellar/mpfr/3.1.3/include , but not in /usr/include or /usr/local/include

I symlink them, and also the libs in /usr/local/Cellar/mpfr/3.1.3/ to /usr/lib or /usr/local/lib . After that, it starts to compile, but then I received the following message:

clang -dynamiclib -Wl,-headerpad_max_install_names -undefined dynamic_lookup -single_module -multiply_defined suppress -L/usr/local/Cellar/r/3.2.2_1/R.framework/Resources/lib -L/usr/local/opt/gettext/lib -L/usr/local/opt/readline/lib -L/usr/local/opt/openssl/lib -o Rmpfr.so Ops.o Summary.o convert.o init.o utils.o -lmpfr -lgmp -F/usr/local/Cellar/r/3.2.2_1/R.framework/.. -framework R -lintl -Wl,-framework -Wl,CoreFoundation
ld: library not found for -lmpfr
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [Rmpfr.so] Error 1
ERROR: compilation failed for package ‘Rmpfr’

Any ideas what can I do?

After several hours trying different options, finally I discovered a work around. I simlink the libs to the R path:
cd /usr/local/Cellar/r/3.2.2_1/R.framework/Resources/lib ln -s /usr/local/Cellar/mpfr/3.1.3/lib/libmpfr.* . ln -s /usr/local/Cellar/gmp/6.0.0a/lib/libgmp* .

After that, I ran:
install.packages('Rmpfr', type = "source", configure.args=c('--with-mpfr-include=/usr/local/include','--with-mpfr-lib=/usr/local/lib'))

And everything compiled OK.

您只需运行brew link gmp mpfr即可创建缺少的符号链接。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM