如何使用c++;R窗口中的代码?

如何使用c++;R窗口中的代码?,r,rcpp,rtools,R,Rcpp,Rtools,我有一个带有Rcpp代码的R包。在任何linux发行版中都可以正常构建。问题是在windows中构建它。我的设置中有以下内容 R版本4.0.1(2020-06-06) Windows10Pro版本1903 Rtools 4.0安装在C:\rtools40 这是Rgui的输出: > utils:::menuInstallLocal() Warning in untar2(tarfile, files, list, exdir, restore_times) : skipping pax

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

  • R版本4.0.1(2020-06-06)
  • Windows10Pro版本1903
  • 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:没有这样的文件或目录
    是没有意义的,因为该目录存在。

    我在
    devtools
    中找到了运气。我在github中上传了我的软件包,并使用
    devtools::install\u github(“myuser/my\u rcpp\u软件包”)
    进行了安装。使用DeVoToice,可以在没有任何问题的情况下构建一个带有C++代码的R包。< /P>是安装在<代码>:/RoToS40/MIWW64/BI/</代码>中的G+编译器。是的,它在那里。好的,但是请注意,代码> DEVToSoS/<代码>调用您已经安装的相同的基本编译器和工具。它可能“只是”设置了一个或两个您没有直接设置的环境变量。