Mac OS X 上的 Rcpp 编译错误(选项“-mtune=”不支持参数“core2”)

问题描述 投票:0回答:1

我在 Mac OS X(14.3.1,截至本文安装了最新版本的 Xcode 工具)上遇到了 Rcpp 错误。我过去广泛使用过 Rcpp,但大约有一年没有使用过,所以我不确定这个编译问题是什么时候出现的。

这是一个可重现的示例:

R version 4.3.3 (2024-02-29) -- "Angel Food Cake"
Copyright (C) 2024 The R Foundation for Statistical Computing
Platform: aarch64-apple-darwin20 (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

  Natural language support but running in an English locale

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

> setwd('/Users/rbradley')

> library (Rcpp)

library (Rcpp)

> sourceCpp ("bug.cpp")

sourceCpp ("bug.cpp")
using C++ compiler: 'Apple clang version 15.0.0 (clang-1500.3.9.4)'
using SDK: 'MacOSX14.4.sdk'
clang++ -arch arm64 -std=gnu++17 -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG   -I"/Library/Frameworks/R.framework/Versions/4.3-arm64/Resources/library/Rcpp/include" -I"/Users/rbradley" -I/opt/R/arm64/include    -fPIC  -mtune=core2  -O0  -g   -c bug.cpp -o bug.o
clang: error: unsupported argument 'core2' to option '-mtune='
make: *** [bug.o] Error 1
Error in sourceCpp("bug.cpp") : Error 1 occurred building shared library.
> sessionInfo()

sessionInfo()
R version 4.3.3 (2024-02-29)
Platform: aarch64-apple-darwin20 (64-bit)
Running under: macOS Sonoma 14.3.1

Matrix products: default
BLAS:   /Library/Frameworks/R.framework/Versions/4.3-arm64/Resources/lib/libRblas.0.dylib 
LAPACK: /Library/Frameworks/R.framework/Versions/4.3-arm64/Resources/lib/libRlapack.dylib;  LAPACK version 3.11.0

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

time zone: America/Los_Angeles
tzcode source: internal

attached base packages:
[1] grDevices utils     datasets  stats     graphics  methods   base     

other attached packages:
[1] Rcpp_1.0.12    dplyr_1.1.4    tidyr_1.3.1    readr_2.1.5    tibble_3.2.1   magrittr_2.0.3

loaded via a namespace (and not attached):
 [1] utf8_1.2.4       R6_2.5.1         tidyselect_1.2.0 tzdb_0.4.0       glue_1.7.0       pkgconfig_2.0.3  generics_0.1.3   lifecycle_1.0.4  cli_3.6.2        fansi_1.0.6     
[11] vctrs_0.6.5      compiler_4.3.3   tools_4.3.3      purrr_1.0.2      hms_1.1.3        pillar_1.9.0     rlang_1.1.3

示例文件bug.cpp的内容为:

#include <Rcpp.h>

using namespace Rcpp;

1;

如果有任何帮助,我将不胜感激!

r rcpp
1个回答
0
投票

这很可能是您的 R 安装配置错误。例如尝试这些命令(我正在 R 容器中执行此操作)

# R CMD config CC
gcc
# R CMD config CXX
g++ -std=gnu++17
# R CMD config CXXFLAGS
-g -O2 -ffile-prefix-map=/build/reproducible-path/r-base-4.3.3=. -fstack-protector-strong -fstack-clash-protection -Wformat -Werror=format-security -fcf-protection -Wdate-time -D_FORTIFY_SOURCE=2
# 

我强烈怀疑您看到的选项来自您的 R 安装(因此在 Unix 系统上对其进行

less $(R RHOME)/etc/Makeconf
操作)和/或某些本地配置(例如
~/.R/Makevars
)。

Rcpp 没有这些选项,因为您可以在存储库中快速检查:

© www.soinside.com 2019 - 2024. All rights reserved.