我很擅长在R中构建软件包,但我正在尝试构建一个已编写的cpp代码包,以便在foreach代码中使用它,因为我在Windows机器上运行代码而我无法通过cpp代码到节点。
我试图在R包中包装的cpp代码来自:
https://github.com/darinchristensen/conley-se
我按照本网站的说明构建软件包:
http://web.mit.edu/insong/www/pdf/rpackage_instructions.pdf
以下是我正在使用的代码:
setwd("C:/Users/Tim/Documents/code/")
library(Rcpp)
library(RcppArmadillo)
RcppArmadillo.package.skeleton("itirun")
然后,我尝试
setwd("C:/Users/Tim/Documents/code/itirun/")
compileAttributes(verbose=TRUE)
然后在终端我转到目录,并运行以下命令,它给出了以下错误消息。我是建立包装的新手,我不明白我做错了什么。我也试过添加编译器标志,但是没有成功,这可能是由于我缺乏理解:
C:\Users\Tim\Documents\code> R CMD build itirun
* checking for file 'itirun/DESCRIPTION' ... OK
* preparing 'itirun':
* checking DESCRIPTION meta-information ... OK
* cleaning src
installing the package to process help pages
Warning: running command '"C:/PROGRA~1/MICROS~2/ROPEN~1/R-
34~1.2/bin/x64/Rcmd.ex
e" INSTALL -l "C:\Users\Tim\AppData\Local\Temp\RtmpA39cZK\Rinst2c0631ac5b" -
-no
-multiarch "C:/Users/Tim/AppData/Local/Temp/RtmpA39cZK/Rbuild2c02fc3722a/itirun
"' had status 1
-----------------------------------
* installing *source* package 'itirun' ...
** libs
c:/Rtools/mingw_64/bin/g++ -m64 -I"C:/PROGRA~1/MICROS~2/ROPEN~1/R-34~1.2/include
" -DNDEBUG -I"C:/Users/Tim/Documents/R/win-library/3.4/Rcpp/include" -I"C:/Use
rs/Tim/Documents/R/win-library/3.4/RcppArmadillo/include" -I"C:/swarm/workspa
ce/External-R-3.4.2/vendor/extsoft/include" -fopenmp -O2 -Wall -mtune=core2
-c RcppExports.cpp -o RcppExports.o
In file included from C:/Users/Tim/Documents/R/win-library/3.4/RcppArmadillo/in
clude/armadillo:53:0,
from C:/Users/Tim/Documents/R/win-library/3.4/RcppArmadillo/in
clude/RcppArmadilloForward.h:46,
from C:/Users/Tim/Documents/R/win-library/3.4/RcppArmadillo/in
clude/RcppArmadillo.h:31,
from RcppExports.cpp:4:
C:/Users/Tim/Documents/R/win-library/3.4/RcppArmadillo/include/armadillo_bits/c
ompiler_setup.hpp:487:118: note: #pragma message: WARNING: support for OpenMP re
quires C++11/C++14; add -std=c++11 or -std=c++14 to compiler flags
#pragma message ("WARNING: support for OpenMP requires C++11/C++14; add -std=
c++11 or -std=c++14 to compiler flags")
^
c:/Rtools/mingw_64/bin/g++ -m64 -I"C:/PROGRA~1/MICROS~2/ROPEN~1/R-34~1.2/include
" -DNDEBUG -I"C:/Users/Tim/Documents/R/win-library/3.4/Rcpp/include" -I"C:/Use
rs/Tim/Documents/R/win-library/3.4/RcppArmadillo/include" -I"C:/swarm/workspa
ce/External-R-3.4.2/vendor/extsoft/include" -fopenmp -O2 -Wall -mtune=core2
-c cpp-functions.cpp -o cpp-functions.o
In file included from C:/Users/Tim/Documents/R/win-library/3.4/RcppArmadillo/in
clude/armadillo:53:0,
from C:/Users/Tim/Documents/R/win-library/3.4/RcppArmadillo/in
clude/RcppArmadilloForward.h:46,
from C:/Users/Tim/Documents/R/win-library/3.4/RcppArmadillo/in
clude/RcppArmadillo.h:31,
from cpp-functions.cpp:4:
C:/Users/Tim/Documents/R/win-library/3.4/RcppArmadillo/include/armadillo_bits/c
ompiler_setup.hpp:487:118: note: #pragma message: WARNING: support for OpenMP re
quires C++11/C++14; add -std=c++11 or -std=c++14 to compiler flags
#pragma message ("WARNING: support for OpenMP requires C++11/C++14; add -std=
c++11 or -std=c++14 to compiler flags")
^
In file included from C:/Users/Tim/Documents/R/win-library/3.4/RcppArmadillo/in
clude/RcppArmadillo.h:38:0,
from cpp-functions.cpp:4:
C:/Users/Tim/Documents/R/win-library/3.4/RcppArmadillo/include/RcppArmadilloAs.
h: In instantiation of 'Rcpp::traits::Exporter<arma::Cube<eT> >::cube_t Rcpp::tr
aits::Exporter<arma::Cube<eT> >::get() [with T = long long int; Rcpp::traits::Ex
porter<arma::Cube<eT> >::cube_t = arma::Cube<long long int>]':
C:/Users/Tim/Documents/R/win-library/3.4/RcppArmadillo/include/RcppArmadilloAs.
h:549:48: required from here
C:/Users/Tim/Documents/R/win-library/3.4/RcppArmadillo/include/RcppArmadilloAs.
h:514:49: error: invalid cast from type 'Rcpp::Vector<19>::iterator {aka Rcpp::i
nternal::Proxy_Iterator<Rcpp::internal::generic_proxy<19> >}' to type 'long long
int*'
dims[0], dims[1], dims[2], false);
^
make: *** [cpp-functions.o] Error 1
Warning: running command 'make -f "Makevars.win" -f "C:/PROGRA~1/MICROS~2/ROPEN~
1/R-34~1.2/etc/x64/Makeconf" -f "C:/PROGRA~1/MICROS~2/ROPEN~1/R-34~1.2/share/mak
e/winshlib.mk" SHLIB_LDFLAGS='$(SHLIB_CXXLDFLAGS)' SHLIB_LD='$(SHLIB_CXXLD)' SHL
IB="itirun.dll" WIN=64 TCLBIN=64 OBJECTS="RcppExports.o cpp-functions.o rcpparma
_hello_world.o"' had status 2
ERROR: compilation failed for package 'itirun'
* removing 'C:/Users/Tim/AppData/Local/Temp/RtmpA39cZK/Rinst2c0631ac5b/itirun'
-----------------------------------
ERROR: package installation failed