1

我有一个带有 Rcpp 代码的 R 包。在任何 linux 发行版中构建良好。问题是在 Windows 中构建它。我的设置中有以下内容

  1. R 版本 4.0.1 (2020-06-06)
  2. Windows 10 专业版 1903 版
  3. Rtools 4.0 安装在C:\rtools40

这是 Rgui 的输出:

> utils:::menuInstallLocal()
Warning in untar2(tarfile, files, list, exdir, restore_times) :
  skipping pax global extended headers
* installing *source* package 'mansched' ...
** using staged installation
** libs
C:/PROGRA~1/R/R-40~1.1/etc/x64/Makeconf:244: warning: overriding commands for target `.m.o'
C:/PROGRA~1/R/R-40~1.1/etc/x64/Makeconf:237: warning: ignoring old commands for target `.m.o'
"C:/rtools40/mingw64/bin/"g++ -std=gnu++11  -I"C:/PROGRA~1/R/R-40~1.1/include" -DNDEBUG  -I'D:/Users/USER/Documents/R/win-library/4.0/Rcpp/include'        -O2 -Wall  -mfpmath=sse -msse2 -mstackrealign -c RcppExports.cpp -o RcppExports.o
"C:/rtools40/mingw64/bin/"g++ -std=gnu++11  -I"C:/PROGRA~1/R/R-40~1.1/include" -DNDEBUG  -I'D:/Users/USER/Documents/R/win-library/4.0/Rcpp/include'        -O2 -Wall  -mfpmath=sse -msse2 -mstackrealign -c assignPool.cpp -o assignPool.o
"C:/rtools40/mingw64/bin/"g++ -std=gnu++11  -I"C:/PROGRA~1/R/R-40~1.1/include" -DNDEBUG  -I'D:/Users/USER/Documents/R/win-library/4.0/Rcpp/include'        -O2 -Wall  -mfpmath=sse -msse2 -mstackrealign -c assignemp.cpp -o assignemp.o
"C:/rtools40/mingw64/bin/"g++ -std=gnu++11  -I"C:/PROGRA~1/R/R-40~1.1/include" -DNDEBUG  -I'D:/Users/USER/Documents/R/win-library/4.0/Rcpp/include'        -O2 -Wall  -mfpmath=sse -msse2 -mstackrealign -c assignmh.cpp -o assignmh.o
"C:/rtools40/mingw64/bin/"g++ -std=gnu++11  -I"C:/PROGRA~1/R/R-40~1.1/include" -DNDEBUG  -I'D:/Users/USER/Documents/R/win-library/4.0/Rcpp/include'        -O2 -Wall  -mfpmath=sse -msse2 -mstackrealign -c gethours.cpp -o gethours.o
"C:/rtools40/mingw64/bin/"g++ -std=gnu++11  -I"C:/PROGRA~1/R/R-40~1.1/include" -DNDEBUG  -I'D:/Users/USER/Documents/R/win-library/4.0/Rcpp/include'        -O2 -Wall  -mfpmath=sse -msse2 -mstackrealign -c getmin.cpp -o getmin.o
"C:/rtools40/mingw64/bin/"g++ -std=gnu++11  -I"C:/PROGRA~1/R/R-40~1.1/include" -DNDEBUG  -I'D:/Users/USER/Documents/R/win-library/4.0/Rcpp/include'        -O2 -Wall  -mfpmath=sse -msse2 -mstackrealign -c isreg.cpp -o isreg.o
"C:/rtools40/mingw64/bin/"g++ -std=gnu++11  -I"C:/PROGRA~1/R/R-40~1.1/include" -DNDEBUG  -I'D:/Users/USER/Documents/R/win-library/4.0/Rcpp/include'        -O2 -Wall  -mfpmath=sse -msse2 -mstackrealign -c isrf.cpp -o isrf.o
"C:/rtools40/mingw64/bin/"g++ -std=gnu++11  -I"C:/PROGRA~1/R/R-40~1.1/include" -DNDEBUG  -I'D:/Users/USER/Documents/R/win-library/4.0/Rcpp/include'        -O2 -Wall  -mfpmath=sse -msse2 -mstackrealign -c mhdb.cpp -o mhdb.o
"C:/rtools40/mingw64/bin/"g++ -std=gnu++11  -I"C:/PROGRA~1/R/R-40~1.1/include" -DNDEBUG  -I'D:/Users/USER/Documents/R/win-library/4.0/Rcpp/include'        -O2 -Wall  -mfpmath=sse -msse2 -mstackrealign -c normemp.cpp -o normemp.o
"C:/rtools40/mingw64/bin/"g++ -std=gnu++11  -shared -s -static-libgcc -o mansched.dll tmp.def RcppExports.o assignPool.o assignemp.o assignmh.o gethours.o getmin.o isreg.o isrf.o mhdb.o normemp.o -LC:/PROGRA~1/R/R-40~1.1/bin/x64 -lR
/usr/bin/sh: line 8: "C:/rtools40/mingw64/bin/"g++ -std=gnu++11 : No such file or directory
no DLL was created
ERROR: compilation failed for package 'mansched'
* removing 'D:/Users/USER/Documents/R/win-library/4.0/mansched'
Warning message:
In install.packages(files[tarballs], .libPaths()[1L], repos = NULL,  :
  installation of package ‘d:/Users/USER/Downloads/mansched-nocxx.tar.gz’ had non-zero exit status

由于该目录存在,因此该错误/usr/bin/sh: line 8: "C:/rtools40/mingw64/bin/"g++ -std=gnu++11 : No such file or directory没有意义。

4

1 回答 1

1

我找到了我的运气devtools。我将我的包上传到 github 并使用devtools::install_github("myuser/my_rcpp_package"). 使用 devtools,可以毫无问题地构建带有 c++ 代码的 R 包。

于 2020-06-20T09:37:26.130 回答