簡體   English   中英

R 中的隱藏 src 文件從 C++ 分頁到 R

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

如附圖所示 我已經安裝了R package。 我試圖將一些文件從src轉換為R語言。 我執行以下步驟:

  • R控制台中打開 package

  • 打開src文件夾中的一個文件作為C++文件。

  • 然后,使用soucreCpp(filename.cpp)

但得到以下信息:

 > 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
                         ^

首先,顯示的編譯說明是一條警告信息 不是錯誤。

/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]

要繞過診斷消息,只需在每個 header 文件的頂部添加:

#define EIGEN_PERMANENTLY_DISABLE_STUPID_WARNINGS

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

有關定義的詳細信息,請參閱: /inst/include/Eigen/src/Core/util/ReenableStupidWarnings.h

當您使用sourceCpp()而不是編譯 package 時,請確保還包括:

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

二是感覺打開提示少了編譯失敗信息。 如前所述,編譯是在使用sourceCpp()的單個腳本的上下文中完成的; 但是,使用現有的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

或者,您可以使用RStudio 項目的Build面板devtools的函數: devtools::build()devtools::install()

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM