[Rcpp-devel] how to create an Rcpp::List in a standalone C++ application?
Romain François
romain at r-enthusiasts.com
Wed Dec 18 12:15:44 CET 2013
Hi,
You need to embed R and load Rcpp, otherwise this won’t work.
You can do this either from scratch. See http://cran.r-project.org/doc/manuals/R-exts.html#Embedding-R-under-Unix_002dalikes
Or you can use RInside.
Romain
Le 18 déc. 2013 à 12:12, Florian Oswald <florian.oswald at gmail.com> a écrit :
> 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
>
>
>
>
>
>
> _______________________________________________
> Rcpp-devel mailing list
> Rcpp-devel at lists.r-forge.r-project.org
> https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.r-forge.r-project.org/pipermail/rcpp-devel/attachments/20131218/9cab6263/attachment.html>
More information about the Rcpp-devel
mailing list