使用 g++ 编译 RInside 时应指定头文件的路径。在 Mac OS X (10.14.2 Mojave) 上有一个 g++ 的参数列表供您参考,希望对您有所帮助。
g++
-I/Library/Frameworks/R.framework/Versions/3.5/Resources/library/RInside/include \
-I/Library/Frameworks/R.framework/Versions/3.5/Resources/library/Rcpp/include \
-I/Library/Frameworks/R.framework/Versions/3.5/Resources/include \
-L/Library/Frameworks/R.framework/Versions/3.5/Resources/lib \
-L/Library/Frameworks/R.framework/Versions/3.5/Resources/library/RInside/lib \
-lR -lRInside -O3 -o test helloworld_rinside.cpp
“helloworld_rinside.cpp”的源代码,http://dirk.eddelbuettel.com/code/rinside.html
// -*- mode: C++; c-indent-level: 4; c-basic-offset: 4; tab-width: 8; -*-
//
// Simple example showing how to do the standard 'hello, world' using embedded R
//
// Copyright (C) 2009 Dirk Eddelbuettel
// Copyright (C) 2010 Dirk Eddelbuettel and Romain Francois
//
// GPL'ed
#include <RInside.h> // for the embedded R via RInside
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);
}