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.
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
RconsoleOpen one file of the
srcfolder as aC++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.
To get around the diagnostic message, just add to the top of each header file:
For details on the define, see:
/inst/include/Eigen/src/Core/util/ReenableStupidWarnings.hAs you are using
sourceCpp()instead of compiling a package, make sure to also include: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 asrvinecopulib, the compilation must be done by compiling the entire package. That is, the package needs to be created usingR CMD build <pkg>and, subsequently, installed withR CMD install <pkg>_x.y.z.tar.gzAlternatively, you can use the
Buildpanel of an RStudio project ordevtools' functions:devtools::build()anddevtools::install()