问题
I followed the steps in R Compiler Tools for Rcpp on macOS (for R 3.6.x), but an error occurs when I try to install RcppArmadillo
. I don't have Xcode.app install, and prefer to use the command line tools instead.
The answers posted here didn't help :(
* installing *source* package ‘RcppArmadillo’ ...
** package ‘RcppArmadillo’ successfully unpacked and MD5 sums checked
** using staged installation
checking whether the C++ compiler works... yes
checking for C++ compiler default output file name... a.out
checking for suffix of executables...
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C++ compiler... yes
checking whether clang++ -std=gnu++11 accepts -g... yes
checking how to run the C++ preprocessor... clang++ -std=gnu++11 -E
checking whether we are using the GNU C++ compiler... (cached) yes
checking whether clang++ -std=gnu++11 accepts -g... (cached) yes
checking whether g++ version is sufficient... almost
configure: WARNING: Compiler self-identifies as being compliant with GNUC extensions but is not g++.
checking for macOS... found
checking for macOS Apple compiler... not found
checking for clang compiler... found
checking for OpenMP compatible version of clang... found and suitable
checking LAPACK_LIBS... system LAPACK found
checking for OpenMP... missing
configure: creating ./config.status
config.status: creating inst/include/RcppArmadilloConfigGenerated.h
config.status: creating src/Makevars
** libs
clang++ -std=gnu++11 -I"/usr/local/Cellar/r/3.6.1_1/lib/R/include" -DNDEBUG -I"/usr/local/lib/R/3.6/site-library/Rcpp/include" -I/usr/local/opt/gettext/include -I/usr/local/opt/readline/include -I/usr/local/include -I../inst/include -fPIC -g -O2 -c RcppArmadillo.cpp -o RcppArmadillo.o
In file included from RcppArmadillo.cpp:22:
In file included from ../inst/include/RcppArmadillo.h:31:
In file included from ../inst/include/RcppArmadilloForward.h:26:
In file included from /usr/local/lib/R/3.6/site-library/Rcpp/include/RcppCommon.h:29:
In file included from /usr/local/lib/R/3.6/site-library/Rcpp/include/Rcpp/r/headers.h:59:
In file included from /usr/local/lib/R/3.6/site-library/Rcpp/include/Rcpp/platform/compiler.h:100:
In file included from /usr/local/clang7/include/c++/v1/cmath:305:
/usr/local/clang7/include/c++/v1/math.h:301:15: fatal error: 'math.h' file not found
#include_next <math.h>
^~~~~~~~
1 error generated.
make: *** [RcppArmadillo.o] Error 1
ERROR: compilation failed for package ‘RcppArmadillo’
* removing ‘/usr/local/lib/R/3.6/site-library/RcppArmadillo’
* restoring previous ‘/usr/local/lib/R/3.6/site-library/RcppArmadillo’
The downloaded source packages are in
‘/private/var/folders/ny/f06ns0d568bgf6s559z8j_9m0000gn/T/Rtmp0t1pHj/downloaded_packages’
Warning message:
In install.packages("RcppArmadillo") :
installation of package ‘RcppArmadillo’ had non-zero exit status
回答1:
A side note mentioned in this answer saved me. The trick is to add the following line to $(R RHOME)/etc/Makeconf
CPPFLAGS = -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk -I/usr/local/include
来源:https://stackoverflow.com/questions/58461195/error-install-rcpparmadillo-on-macos-catalina