Rcpp: Failed Installation

Created on 12 Apr 2020  Â·  14Comments  Â·  Source: RcppCore/Rcpp

I have been unable to install the package in my make.
This is ther error:

Retrieving 'https://cloud.r-project.org/src/contrib/Rcpp_1.0.4.6.tar.gz' ...
    OK [file is up to date]
Installing Rcpp [1.0.4.6] ...
    FAILED
Error installing package 'Rcpp':
================================

* installing *source* package ‘Rcpp’ ...
** package ‘Rcpp’ successfully unpacked and MD5 sums checked
** using staged installation
make: *** No rule to make target `clean'.  Stop.
./cleanup: line 39: cd: vignettes/rmd/: No such file or directory
** libs
/usr/local/bin/gcc-9 -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG -I../inst/include/  -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk -I/usr/local/include  -fPIC  -Wall -g -O2  -c api.cpp -o api.o
/usr/local/bin/gcc-9 -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG -I../inst/include/  -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk -I/usr/local/include  -fPIC  -Wall -g -O2  -c attributes.cpp -o attributes.o
/usr/local/bin/gcc-9 -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG -I../inst/include/  -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk -I/usr/local/include  -fPIC  -Wall -g -O2  -c barrier.cpp -o barrier.o
/usr/local/bin/gcc-9 -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG -I../inst/include/  -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk -I/usr/local/include  -fPIC  -Wall -g -O2  -c date.cpp -o date.o
/usr/local/bin/gcc-9 -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG -I../inst/include/  -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk -I/usr/local/include  -fPIC  -Wall -g -O2  -c module.cpp -o module.o
/usr/local/bin/gcc-9 -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG -I../inst/include/  -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk -I/usr/local/include  -fPIC  -Wall -g -O2  -c rcpp_init.cpp -o rcpp_init.o
/usr/local/bin/gcc-9 -dynamiclib -Wl,-headerpad_max_install_names -undefined dynamic_lookup -single_module -multiply_defined suppress -L/Library/Frameworks/R.framework/Resources/lib -L/usr/local/lib -o Rcpp.so api.o attributes.o barrier.o date.o module.o rcpp_init.o -F/Library/Frameworks/R.framework/.. -framework R -Wl,-framework -Wl,CoreFoundation
installing to /Users/heverz/Documents/R_projects/extractus/renv/staging/1/00LOCK-Rcpp/00new/Rcpp/libs
** R
** inst
** byte-compile and prepare package for lazy loading
** help
*** installing help indices
** building package indices
** installing vignettes
** testing if installed package can be loaded from temporary location
Error: package or namespace load failed for ‘Rcpp’ in dyn.load(file, DLLpath = DLLpath, ...):
 unable to load shared object '/Users/heverz/Documents/R_projects/extractus/renv/staging/1/00LOCK-Rcpp/00new/Rcpp/libs/Rcpp.so':
  dlopen(/Users/heverz/Documents/R_projects/extractus/renv/staging/1/00LOCK-Rcpp/00new/Rcpp/libs/Rcpp.so, 6): Symbol not found: __ZNSt15basic_streambufIcSt11char_traitsIcEE5imbueERKSt6locale
  Referenced from: /Users/heverz/Documents/R_projects/extractus/renv/staging/1/00LOCK-Rcpp/00new/Rcpp/libs/Rcpp.so
  Expected in: flat namespace
 in /Users/heverz/Documents/R_projects/extractus/renv/staging/1/00LOCK-Rcpp/00new/Rcpp/libs/Rcpp.so
Error: loading failed
Execution halted
ERROR: loading failed
* removing ‘/Users/heverz/Documents/R_projects/extractus/renv/staging/1/Rcpp’
Error: install of package 'Rcpp' failed

Is the problem do to gcc compiler? Should I use a different one (clang)?
This my .R/Makevars:

CC=/opt/local/bin/gcc-mp-4.7
CXX=/opt/local/bin/g++-mp-4.7
CPLUS_INCLUDE_PATH=/opt/local/include:$CPLUS_INCLUDE_PATH
LD_LIBRARY_PATH=/opt/local/lib:$LD_LIBRARY_PATH
CXXFLAGS= -g0 -O2 -Wall
MAKE=make -j4

Best

All 14 comments

in my make

What exactly are you trying to do? This is an _R package_ which one installs _from within R_ via install.packages("Rcpp") or, if you wish, from the release tarball via R CMD INSTALL Rcpp_1.0.4.6.tar.gz.

There is no provision for make; make install. As there isn't for any of the 15000 CRAN packages.

/usr/local/bin/gcc-9 -I"/Library/Frameworks/R.framework/Resources/include"

Based off of the compilation trail, R is being used on macOS with gcc as the compiler.

Are you using the official CRAN binaries for _R_? Or are you working with homebrew? Alternatively, have you decided to compile from source? General rule of thumb is clang on macOS for compilation.

$ nm /usr/lib/libc++.dylib | grep __ZNSt15basic_streambufIcSt11char_traitsIcEE5imbueERKSt6locale
$ nm /usr/lib/libstdc++.dylib | grep __ZNSt15basic_streambufIcSt11char_traitsIcEE5imbueERKSt6locale
000000000002bdb4 T __ZNSt15basic_streambufIcSt11char_traitsIcEE5imbueERKSt6locale

You've configured your system to use gcc as the compiler, but haven't told it to use libstdc++ as opposed to libc++. You need to tell R to use -stdlib=libstdc++ during the linking step. (I don't recall exactly how to do that.)

Nice, I will check out online if can figure out how to do that

What exactly are you trying to do? This is an _R package_ which one installs _from within R_ via install.packages("Rcpp") or, if you wish, from the release tarball via R CMD INSTALL Rcpp_1.0.4.6.tar.gz.
@eddelbuettel
Yes that is what I run from R: install.packages("Rcpp") and what you saw is what I got.

Are you using the official CRAN binaries for _R_?
@coatless I believe that I installed it from CRAN, but I am going to double check for that.

Sorry for your troubles. I only work on Linux where things just work.

@kevinushey
I haven't find instructions to use ibstdc++ yet , but a simple workaround for mac users (that have not transitioned yet to Linux :P) is to use the binary: install.packages("Rcpp", type = "mac.binary")

@c1au6i0 also, and you may have seen this already, there is a contributed resource in the page(s) maintained by @coatless:
https://thecoatlessprofessor.com/programming/r-compiler-tools-for-rcpp-on-macos/

This area seems to change way too fast and randomly between macOS releases and CRAN toolchain updates so I am not really trying to stay current. This is something the macOS user community needs to sort out. I can wish they'd also help test, but sadly that appears to be too much to ask for.

Nice, thanks!:)

We point to that somewhat prominently from the RcppArmadillo, maybe we should do it here too...

No need I think. With the transition to R 4.0 right around the corner, the toolchain simplifies back to:

sudo xcode-select --install

(That said, this uses the latest SDK instead of the 10.13 SDK and so on. The important parts is everything should just "work" at the cost of OpenMP on macOS.)

Thanks. I had not fully groked the 'should just work' as I was busy shaking my head over the loss of OpenMP which seems ... quite a pill to swallow. But hey, at least the hardware is also more expensive.

Just in case someone had similar problems. Just following these steps and especially, step 3, set the right compiler and fixes the issue. https://github.com/Rdatatable/data.table/wiki/Installation

Thanks (and your URL was not quite using the right markdown syntax so I simplified / fixed it).

Was this page helpful?
0 / 5 - 0 ratings

Related issues

epipping picture epipping  Â·  7Comments

ivan-krukov picture ivan-krukov  Â·  8Comments

steve-s picture steve-s  Â·  4Comments

nettoyoussef picture nettoyoussef  Â·  6Comments

klmr picture klmr  Â·  4Comments