mercredi 21 février 2018

Package building in R with Rcpp -- failure to build a package

I am very new to building packages in R, but I am trying to build a package of already written cpp code to use it in a foreach code, as I am running my code on a Windows machine and I can't pass the cpp code to the nodes.

The cpp code I am trying to wrap in an R package comes from:

https://github.com/darinchristensen/conley-se

I am following the instructions from this website to build the package:

http://web.mit.edu/insong/www/pdf/rpackage_instructions.pdf

Here is the code I am using:

setwd("C:/Users/Tim/Documents/code/")
library(Rcpp)
library(RcppArmadillo)
RcppArmadillo.package.skeleton("itirun")

Then, I try

setwd("C:/Users/Tim/Documents/code/itirun/")
compileAttributes(verbose=TRUE)

And then in terminal I go to the directory, and run the following command which gives me the following error message. I am a newbie at building packages, and I fail to understand what I am doing wrong. I also tried adding compiler flags, but wasn't successful which is probably due to my lack of understanding:

     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

Aucun commentaire:

Enregistrer un commentaire