简体   繁体   中英

Covert src files in R pagate from C++ to R

如附图所示 I have installed the R package. I tried to convert some files from src into R language. I do the following steps:

  • Open the package in the R console

  • Open one file of the src folder as a C++ file.

  • Then, use soucreCpp(filename.cpp)

but got the following:

 > Rcpp::sourceCpp('src/vinecopulib-interface.cpp')
In file included from vinecopulib-interface.cpp:1:
In file included from /Users/fadhahalanazi/Downloads/rvinecopulib-master/src/../inst/include/vinecopulib-wrappers.hpp:15:
In file included from /Library/Frameworks/R.framework/Versions/4.0/Resources/library/RcppEigen/include/RcppEigen.h:25:
In file included from /Library/Frameworks/R.framework/Versions/4.0/Resources/library/RcppEigen/include/RcppEigenForward.h:30:
In file included from /Library/Frameworks/R.framework/Versions/4.0/Resources/library/RcppEigen/include/Eigen/Dense:1:
In file included from /Library/Frameworks/R.framework/Versions/4.0/Resources/library/RcppEigen/include/Eigen/Core:540:[![as shown here][1]][1]
/Library/Frameworks/R.framework/Versions/4.0/Resources/library/RcppEigen/include/Eigen/src/Core/util/ReenableStupidWarnings.h:14:30: warning: pragma diagnostic pop could not pop, no matching push [-Wunknown-pragmas]
    #pragma clang diagnostic pop
                         ^

First, the compilation note shown is a warning message ; not an error.

/Library/Frameworks/R.framework/Versions/4.0/Resources/library/RcppEigen/include/Eigen/src/Core/util/ReenableStupidWarnings.h:14:30:
 warning: pragma diagnostic pop could not pop, no matching push [-Wunknown-pragmas]

To get around the diagnostic message, just add to the top of each header file:

#define EIGEN_PERMANENTLY_DISABLE_STUPID_WARNINGS

// Then, include the header file
#include <RcppEigen.h>

For details on the define, see: /inst/include/Eigen/src/Core/util/ReenableStupidWarnings.h

As you are using sourceCpp() instead of compiling a package, make sure to also include:

// [[Rcpp::depends(RcppEigen)]]

Second, I have a feeling that the opening prompt is missing the compilation failure message. As hinted previously, the compilation is being done in the context of a single script with sourceCpp() ; however, working with an existing R package such as rvinecopulib , the compilation must be done by compiling the entire package. That is, the package needs to be created using R CMD build <pkg> and, subsequently, installed with R CMD install <pkg>_x.yztar.gz

Alternatively, you can use the Build panel of an RStudio project or devtools ' functions: devtools::build() and devtools::install()

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM