简体   繁体   English

R 中的隐藏 src 文件从 C++ 分页到 R

[英]Covert src files in R pagate from C++ to R

如附图所示 I have installed the R package.我已经安装了R package。 I tried to convert some files from src into R language.我试图将一些文件从src转换为R语言。 I do the following steps:我执行以下步骤:

  • Open the package in the R consoleR控制台中打开 package

  • Open one file of the src folder as a C++ file.打开src文件夹中的一个文件作为C++文件。

  • Then, use soucreCpp(filename.cpp)然后,使用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:要绕过诊断消息,只需在每个 header 文件的顶部添加:

#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有关定义的详细信息,请参阅: /inst/include/Eigen/src/Core/util/ReenableStupidWarnings.h

As you are using sourceCpp() instead of compiling a package, make sure to also include:当您使用sourceCpp()而不是编译 package 时,请确保还包括:

// [[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() ;如前所述,编译是在使用sourceCpp()的单个脚本的上下文中完成的; however, working with an existing R package such as rvinecopulib , the compilation must be done by compiling the entire package.但是,使用现有的R package(例如rvinecopulib ),必须通过编译整个 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 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()或者,您可以使用RStudio 项目的Build面板devtools的函数: devtools::build()devtools::install()

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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