在 macOS Catalina 上安装 RcppArmadillo 时出错 [重复]

Posted

技术标签:

【中文标题】在 macOS Catalina 上安装 RcppArmadillo 时出错 [重复]【英文标题】:Error install RcppArmadillo on macOS Catalina [duplicate] 【发布时间】:2019-10-19 06:41:48 【问题描述】:

我按照R Compiler Tools for Rcpp on macOS (for R 3.6.x) 中的步骤进行操作,但是当我尝试安装RcppArmadillo 时出现错误。我没有安装 Xcode.app,而是更喜欢使用命令行工具。

here 发布的答案没有帮助:(

* 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】:

this answer 中提到的一个旁注救了我。诀窍是将以下行添加到$(R RHOME)/etc/Makeconf

CPPFLAGS = -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk -I/usr/local/include

【讨论】:

以上是关于在 macOS Catalina 上安装 RcppArmadillo 时出错 [重复]的主要内容,如果未能解决你的问题,请参考以下文章

macOS Catalina 上的 RODBC

颤振 - xcode11 - macOS catalina - cocoapod 安装错误

macos catalina安装python3

MacBook Pro(13 英寸,2011 年末)A1278 官方最高支持macOS High Sierra,使用macOS Catalina Patcher成功安装macOS Catalina

在没有自制软件的情况下安装了 macos catalina 中的 mongod 命令有问题?

MacOS 10.15 Catalina 的颤振问题