Я пытался что-то вроде ниже (грубый пример):
test. cpp:
#include <Rcpp.h>
#include <string>
// [[Rcpp::export]]
RcppExport int R_load_lib(SEXP R_strDllPath);
int R_load_lib(SEXP R_strDllPath)
{
int nStatus;
std::string strDllPath = Rcpp::as<std::string>(R_strDllPath);
nStatus = LoadLibrary(strDllPath.c_str());
Rcpp::Rcout << "LoadLib status is " << nStatus << "\n";//This get printed and then crash happens
return nStatus;
}
Шаги компиляции для кода C ++ (С использованием cygwin):
g++ -static-libgcc -static-libstdc++ -L$(R_HOME)/bin/x64 -lR
-L$(R_HOME)/library/Rcpp/libs/x64 -lRcpp -fPIC -shared test.o -o test.dll
test.R:
dyn.load("test.dll")
status<-.Call("R_load_lib", "D:/R_test/sample.dll")