[Rcpp-devel] how to create an Rcpp::List in a standalone C++ application?

Florian Oswald florian.oswald at gmail.com
Wed Dec 18 12:12:30 CET 2013


Hi All,

I have a C++ class that I build and test without the help of Rcpp.

I use Rcpp as an interface, inputting and outputting data from and to the
class. I'm stuck at the outputter. Ideally I would like to have this at the
end of my program:

Rcpp::List Results = MyClass.ExportToR();

where ExportToR is a method that creates an Rcpp::List from members of
MyClass. However, I'm unable to use components of Rcpp.h in my code; In
particular, I'm unable to make this toy example work:

#include <iostream>
#include <cstdlib>
#include <blitz/array.h>
#include <Rcpp.h>
#include <R.h>

using namespace std;

int main(int argc, char *argv[])
{
   Rcpp::IntegerVector d;

   // Rcpp::List L; want to use
   // L to output results to R.

  return EXIT_SUCCESS;
}

I compile it with

llvm-g++-4.2 -arch x86_64
-I/Library/Frameworks/R.framework/Resources/include -DNDEBUG -W
-I/usr/local/include -I/usr/local/include
-I"/Library/Frameworks/R.framework/Versions/3.0/Resources/library/Rcpp/include"
-L"/Library/Frameworks/R.framework/Versions/3.0/Resources/library/Rcpp/lib/"
-L"/Library/Frameworks/R.framework/Versions/3.0/Resources/lib" export.cpp
-lRcpp -lR -o  export

which compiles, but produces a segfault.

Thanks for any help!

Florian
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.r-forge.r-project.org/pipermail/rcpp-devel/attachments/20131218/ed5f3296/attachment.html>


More information about the Rcpp-devel mailing list