I have tried this cpp code with Rcpp header.
#include <Rcpp.h>
using namespace Rcpp;
// This is a simple example of exporting a C++ function to R. You can
// source this function into an R session using the Rcpp::sourceCpp
// function (or via the Source button on the editor toolbar).
// [[Rcpp::export]]
NumericVector timesTwo(NumericVector x) {
return x * 2;
}
/*** R
timesTwo(42)
*/
First i have compiled like g++ -I/usr/share/R/include -I/usr/lib/R/site-library/Rcpp/include -c rcpp.cpp
. Later i used g++ -I/usr/share/R/include -I/usr/lib/R/site-library/Rcpp/include -c rcpp.cpp -L/usr/share/R/include -L/usr/lib/R/site-library/Rcpp/include
for linking. But both creates a object file. But i need to show the output.
- For making object file executable, i used
chmod u+x rcpp.o
command. - For unning ./rcpp
But this creates error.
bash: ./reg: No such file or directory
But i am compile the code from the same directory itself. Anybody know how to resolve the issue.