我让 RInside 示例运行和工作,但我必须手动添加链接器选项:“-F/Library/Frameworks/R.framework/.. -framework R”在 g++ 的末尾(在 Mac Snow Leopard 10.6.8 上使用 Xcode 3.x)。它有效,但我不知道为什么。谁能说出这些选项的实际作用?我在这个列表中找不到它:http: //gcc.gnu.org/onlinedocs/gcc/Link-Options.html
这是原始代码:
#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);
}
这是我在 NetBeans 中看到的链接器调用:
g++ -o dist/Debug/GNU-MacOSX/callingrproject build/Debug/GNU-MacOSX/main.o -L/Library/Frameworks/R.framework/Resources/lib -L/Library/Frameworks/R.framework/Resources/ library/Rcpp/lib -L/Library/Frameworks/R.framework/Resources/library/RInside/lib -L/Library/Frameworks/R.framework/Libraries -L/Library/Frameworks/R.framework/Resources/lib - L/Library/Frameworks/R.framework/Resources/library -L/Library/Frameworks/R.framework/Resources/modules -lRcpp -lRInside -lRlapack -lRblas -F/Library/Frameworks/R.framework/.. -framework R
最后一部分是我必须手动添加的。没有它,我得到了这两个链接错误:
Undefined symbols:
"_Rf_mkString", referenced from:
Rcpp::wrap(char const*)in main.o
"_R_NilValue", referenced from:
Rcpp::wrap(char const*)in main.o