-2

Updated information

I finally got to make souceCpp works, but still couldn't get the source code in R.

I tried the following:

Rcpp::sourceCpp('src/vinecopulib-interface.cpp')
> try <- Rcpp::sourceCpp('src/vinecopulib-interface.cpp')
> try
$functions
 [1] "pseudo_obs_cpp"                 "bicop_check_cpp"                "bicop_select_cpp"              
 [4] "bicop_pdf_cpp"                  "bicop_cdf_cpp"                  "bicop_hfunc1_cpp"              
 [7] "bicop_hfunc2_cpp"               "bicop_hinv1_cpp"                "bicop_hinv2_cpp"               
[10] "bicop_sim_cpp"                  "bicop_loglik_cpp"               "bicop_par_to_tau_cpp"          
[13] "bicop_tau_to_par_cpp"           "rvine_structure_cpp"            "rvine_structure_check_cpp"     
[16] "rvine_structure_sim_cpp"        "rvine_matrix_check_cpp"         "vinecop_check_cpp"             
[19] "vinecop_inverse_rosenblatt_cpp" "vinecop_rosenblatt_cpp"         "vinecop_sim_cpp"               
[22] "vinecop_pdf_cpp"                "vinecop_cdf_cpp"                "vinecop_loglik_cpp"            
[25] "vinecop_mbicv_cpp"              "vinecop_select_cpp"             "fit_margins_cpp"               

Then, I tried to get, try$functions[26] but did not return me the function in R code.

as shown in the attached figureI 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
                         ^

1 Answers1

0

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.y.z.tar.gz

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

coatless
  • 20,011
  • 13
  • 69
  • 84
  • Thanks for your help. Really appreciated. But I have got an error: > `devtools::build("rvinecopulib") Error: `pkg` must exist` ` –  Jan 10 '22 at 11:00
  • I edit my question. Thanks a lot. –  Jan 10 '22 at 12:46