我有这个Makefile码的.

PKG_CC = clang-15
PKG_CXX = clang++-15
PKG_CXXFLAGS = -g -O0 -fopenmp
PKG_LIBS = $(SHLIB_OPENMP_CXXFLAGS)
CXX_STD = CXX11
PKG_CPPFLAGS = -UDEBUG -g

当我运行devtools::install()时,我看到的是g++ -std=gnu++11 -I"/usr/share/R/include"...而不是clang...,这是我预期的,因为下一个测试起作用了:


> pkgbuild::check_build_tools(debug = TRUE)
Trying to compile a simple C file
Running /usr/lib/R/bin/R CMD SHLIB foo.c
using C compiler: ‘Ubuntu clang version 15.0.7’
clang-15 -I"/usr/share/R/include" -DNDEBUG       -fpic  -g -O2 -ffile-prefix-map=/build/r-base-JhpCKt/r-base-4.3.0=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2  -c foo.c -o foo.o
clang-15 -shared -L/usr/lib/R/lib -Wl,-Bsymbolic-functions -flto=auto -ffat-lto-objects -flto=auto -Wl,-z,relro -o foo.so foo.o -L/usr/lib/R/lib -lR
 
Your system is ready to build packages!

到目前为止,我删除了.Rproj.user个,并try

devtools::clean_dll()
devtools::document()
devtools::install()

推荐答案

您可以忽略此处的所有devtools个调用以及对RStudio的所有引用:这些只是添加的层.Everything最终会呼叫R CMD INSTALL,因此您可以直接拨打.

简而言之,您的文件可能有错误的变量.下面是最小的一个(作为我的一个实际子集,我用它在gccclang之间切换)

CLANGVER=-15
CLANGLIB=-stdlib=libc++
CXX=$(CCACHE) clang++$(CLANGVER) $(CLANGLIB)
CXX11=$(CCACHE) clang++$(CLANGVER) $(CLANGLIB)
CXX14=$(CCACHE) clang++$(CLANGVER) $(CLANGLIB)
CXX17=$(CCACHE) clang++$(CLANGVER) $(CLANGLIB)
CXX20=$(CCACHE) clang++$(CLANGVER) $(CLANGLIB)
CC=$(CCACHE) clang$(CLANGVER)
SHLIB_CXXLD=clang++$(CLANGVER) $(CLANGLIB)
CXXFLAGS=-Wall -O3 -pedantic
CXX11FLAGS=-Wall -O3 -pedantic
CXX14FLAGS=-Wall -O3 -pedantic
CXX17FLAGS=-Wall -O3 -pedantic
CXX20FLAGS=-Wall -O3 -pedantic

我用CLANGVER,因为Ubuntu通常给我一个 Select ,我用VER代表gcc.通常设置为CCACHE(设置为ccache),但您也可以在没有它的情况下使用它,如以下程序包中的完整日志(log)所示:

edd@rob:~/git/rcppexamples(master)$ ./cleanup; install.r   # install.r wraps R CMD INSTALL
* installing *source* package found in current working directory ...
* installing *source* package ‘RcppExamples’ ...
** using staged installation
** libs
using C++ compiler: ‘Ubuntu clang version 15.0.7’
clang++-15 -stdlib=libc++ -I"/usr/share/R/include" -DNDEBUG  -I'/usr/local/lib/R/site-library/Rcpp/include'     -fpic  -Wall -O3 -pedantic -c DataFrameExample.cpp -o DataFrameExample.o
clang++-15 -stdlib=libc++ -I"/usr/share/R/include" -DNDEBUG  -I'/usr/local/lib/R/site-library/Rcpp/include'     -fpic  -Wall -O3 -pedantic -c DateExample.cpp -o DateExample.o
clang++-15 -stdlib=libc++ -I"/usr/share/R/include" -DNDEBUG  -I'/usr/local/lib/R/site-library/Rcpp/include'     -fpic  -Wall -O3 -pedantic -c FactorExample.cpp -o FactorExample.o
clang++-15 -stdlib=libc++ -I"/usr/share/R/include" -DNDEBUG  -I'/usr/local/lib/R/site-library/Rcpp/include'     -fpic  -Wall -O3 -pedantic -c ListExample.cpp -o ListExample.o
clang++-15 -stdlib=libc++ -I"/usr/share/R/include" -DNDEBUG  -I'/usr/local/lib/R/site-library/Rcpp/include'     -fpic  -Wall -O3 -pedantic -c MatrixExample.cpp -o MatrixExample.o
clang++-15 -stdlib=libc++ -I"/usr/share/R/include" -DNDEBUG  -I'/usr/local/lib/R/site-library/Rcpp/include'     -fpic  -Wall -O3 -pedantic -c NumericVectorExample.cpp -o NumericVectorExample.o
clang++-15 -stdlib=libc++ -I"/usr/share/R/include" -DNDEBUG  -I'/usr/local/lib/R/site-library/Rcpp/include'     -fpic  -Wall -O3 -pedantic -c RNGs.cpp -o RNGs.o
clang++-15 -stdlib=libc++ -I"/usr/share/R/include" -DNDEBUG  -I'/usr/local/lib/R/site-library/Rcpp/include'     -fpic  -Wall -O3 -pedantic -c RcppExports.cpp -o RcppExports.o
clang++-15 -stdlib=libc++ -I"/usr/share/R/include" -DNDEBUG  -I'/usr/local/lib/R/site-library/Rcpp/include'     -fpic  -Wall -O3 -pedantic -c StringVectorExample.cpp -o StringVectorExample.o
clang++-15 -stdlib=libc++ -shared -L/usr/lib/R/lib -Wl,-Bsymbolic-functions -flto=auto -ffat-lto-objects -flto=auto -Wl,-z,relro -o RcppExamples.so DataFrameExample.o DateExample.o FactorExample.o ListExample.o MatrixExample.o NumericVectorExample.o RNGs.o RcppExports.o StringVectorExample.o -L/usr/lib/R/lib -lR
installing to /usr/local/lib/R/site-library/00LOCK-rcppexamples/00new/RcppExamples/libs
** R
** inst
** byte-compile and prepare package for lazy loading
** help
*** installing help indices
** building package indices
** testing if installed package can be loaded from temporary location
** testing if installed package can be loaded from final location
** testing if installed package keeps a record of temporary installation path
* DONE (RcppExamples)
edd@rob:~/git/rcppexamples(master)$ 

因此,简而言之,你使用了错误的变量.它们不同于我们必须在包裹中使用的内容,以及它们的src/Makevars~/.R/Makevars中的内容.这里没有前缀PKG_,‘global’优先于R在它自己的$RHOME/etc/Makeconf中的前缀.

R相关问答推荐

使用lapply的重新定位功能

使用sensemakr和fixest feols模型(R)

是否可以 Select 安装不带文档的R包以更有效地存储?

无法运行通过R中的Auto.arima获得的ARIMA模型

在垂直轴中包含多个ggplot2图中的平均值

如何计算R数据集中每个女性的子元素数量?

如何在emmeans中计算连续变量的对比度

在嵌套列表中查找元素路径的最佳方法

使用data.table::fcase()而不是dplyr::case_When()时保持值

有没有办法使用ggText,<;Sub>;&;<;sup>;将上标和下标添加到同一元素?

如何在R中平滑地绘制线图(不拟合)?

更新R中的数据表(使用data.table)

如何在使用箭头R包(箭头::OPEN_DATASSET)和dplyr谓词时编写具有整齐计算的函数?

如果满足条件,则替换列的前一个值和后续值

如何使用ggplot2根据绘图中生成的斜率对小平面进行排序?

替换在以前工作的代码中有x行&q;错误(geom_sf/gganimate/dow_mark)

conditionPanel不考虑以下条件

在R中添加要打印的垂直线

合并多个数据帧,同时将它们的名称保留为列名?

R:水平旋转图