[英]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.