R を C++ プログラムに組み込みたい。そこで、R、Rcpp、RInside もインストールしました。しかし、UNIX で g++ を使用してコンパイルしているときに、多くの「未定義参照」エラーが発生します。コンパイルのために私が与えるコマンドは
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);
}
エラー:
Undefined reference to R_ClassSymbol
Undefined reference to R_NilValue
R 変数に対して同様の 110 の未定義エラーが発生します。R およびその他のパッケージをデフォルトの場所ではなく、自分の場所にインストールしました。このエラーで 2 日間立ち往生しています。リンクなど、すべてを正しく行っているようです。よろしくお願いします。