Undefined link error when linking to R and RInside libraries from C ++ code using the g ++ compiler on UNIX

I want to embed R in a C ++ program. So I installed R, Rcpp and RInside. But during compilation with g ++ on UNIX, I get many undefined references to "errors". The command I give to compile

g ++ -I / path / to / R / include -I / path / to / Rcpp / include -I / path / to / RInside / include -L / path / to / R / libs -L / path / to / Rcpp / libs -L / path / to / RInside / libs test.cpp -lRlapack -lRcpp -lRblas -lRInside "

test.cpp:

#include <RInside.h>                   
int main(int argc, char *argv[]) {
    RInside R(argc, argv);              // create an embedded R instance
    R["txt"] = "Hello, world!\n";   // assign a char* (string) to 'txt'
    R.parseEvalQ("cat(txt)");           // eval the init string, ignoring any returns
    exit(0);
}

Errors:

Undefined reference to R_ClassSymbol
Undefined reference to R_NilValue

I get similar 110 undefined errors for R variables. I installed R and other packages in my location, not the default. I am stuck with this error for 2 days. I seem to be doing everything right, like binding, etc. Thanks in advance.

+3
3

RInside examples/standard/ ( MPI, ). Makefile.

R - , , -lR. , () .

+2

- .... -enable-R-shlib . , . .

+1

Source: https://habr.com/ru/post/1785235/


All Articles