I got the RInside example to run and work but I had to manually add the linker option: "-F/Library/Frameworks/R.framework/.. -framework R" at the end for g++ (on Mac Snow Leopard 10.6.8 with Xcode 3.x). It works, but I don't know why. Can anyone say what these options actually do ? I could not find it on this list: http://gcc.gnu.org/onlinedocs/gcc/Link-Options.html
Here is the original code:
#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);
}
Here is the linker call as I saw it in 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
The last part is what I had to add manually. Without that I got these two linkage errors:
Undefined symbols:
"_Rf_mkString", referenced from:
Rcpp::wrap(char const*)in main.o
"_R_NilValue", referenced from:
Rcpp::wrap(char const*)in main.o