-2

I have a problem in building the basic example rcpp_hello_world. I have followed the example referred at http://blog.fellstat.com/?p=170

It is all ok up to the linking, when I find the following error

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

here the code of the main.cpp file

/*
 * 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

I'm sorry for disordered post I'm thankful for any hint

coatless
  • 20,011
  • 13
  • 69
  • 84
luigi
  • 1
  • 1

1 Answers1

1

For starters, you have the wrong tag. It is an rinside question, not an rcpp question.

Next, for rinside, we have eight (yes, 8) directories with working example. Change directory into examples/standard/ and say make. Well over a dozen examples will build.

These serve as a reference, and a working build environment. If you choose to ignore these as help, your build may fail. Which is why we give you a (tested !!) environment in which it will work.

Dirk Eddelbuettel
  • 360,940
  • 56
  • 644
  • 725