我在构建基本示例 rcpp_hello_world 时遇到问题。我遵循了 http://blog.fellstat.com/?p=170中提到的示例
当我发现以下错误时,链接一切正常
Building target: MyCppPackage_4
Invoking: Cross G++ Linker
g++ -L/usr/local/R/lib64/R/lib -o "MyCppPackage_4" ./src/RcppExports.o ./src/main.o ./src/rcpp_hello_world.o /usr/local/R/lib64/R/library/Rcpp/libs/Rcpp.so /usr/local/R/lib64/R/library/RInside/lib/libRInside.so -lR -lRblas
./src/main.o: In function `main':
/home/luigi/workspace-mars/MyCppPackage_4/Debug/../src/main.cpp:22: undefined reference to `rcpp_hello_world'
collect2: error: ld returned 1 exit status
make: *** [MyCppPackage_4] Error 1
这里是 main.cpp 文件的代码
/*
* main.cpp
*
* Created on: Jun 13, 2016
* Author: luigi
*/
#ifdef INSIDE
#include <Rcpp.h>
#include <RInside.h> // for the embedded R via RInside
#include "rcpp_hello_world.h"
using namespace Rcpp;
using namespace std;
//RcppExport SEXP rcpp_hello_world();
#include <unistd.h>
int main(int argc, char *argv[]) {
RInside R(argc, argv); // create an embedded R instance
SEXP s = rcpp_hello_world();
Language call("print",s);
call.eval();
return 0;
}
#endif
对于混乱的帖子我很抱歉我很感谢任何提示