[Rcpp-devel] Rcpp::wrap segmentation fault
Dirk Eddelbuettel
edd at debian.org
Sun Nov 21 13:57:25 CET 2010
On 21 November 2010 at 13:46, marc michalewicz wrote:
| Hi,
|
| I use R 2.12.0 on Fedora FC13 and experience a segmentatioin fault when using a standard example from the artice "Rcpp: Seamless R and C++ integration" by D. Eddelbuettel:
|
| When trying out this quite small and simple example:
|
| <snip>
| #include <Rcpp.h>
|
| int main ()
| {
| SEXP x;
| std::vector<std::map<std::string,int> > v;
| std::map<std::string, int> m1;
| std::map<std::string, int> m2;
| m1["foo"]=1; m1["bar"]=2;
| m2["foo"]=1; m2["bar"]=2; m2["baz"]=3;
|
| v.push_back( m1 );
| v.push_back( m2 );
| x = Rcpp::wrap( v );
| }
|
| <snip>
| (built with "g++ -g -I/usr/lib64/R/library/Rcpp/include -I/usr/include/R -L/usr/lib64/R/library/Rcpp/lib -lRcpp -Wl,-rpath,/usr/lib64/R/library/Rcpp/lib -lRcpp example.cpp")
|
| it results in a segmentation fault in libR during the call to wrap.
|
| What is wrong ?
Your understanding, mostly. See the 'Writing R Extentions' manual for an
introduction to writing compiled R functions.
Basically, R itself is the main(). You never see that code. You simply write
functions all confirming to
SEXP myfunction(SEXP a, SEXP b, ...)
which take one or more SEXP objects and return one SEXP object. You call
this from as
val <- .Call("myfunction", list(foo=1:3, bar="ABC"), cumsum(1:100))
which would supply two such arguments (the list and the vector).
Such 'myfunction' functions are now easier to write with Rcpp---as we take of
conversion from/to SEXP and also generally map the SEXP, the representation
of your R objects, to C++ objects.
There are plenty of examples in the paper Romain and I wrote, here in the
list archives and at other places. The "inline" package helps you do all
this at the R prompt meaning you do not need to call make, g++, ... yourself.
Hope this helps, Dirk
| Apart from this, my R installation works perfect, anything else too.
|
| Thanks for any help on this,
|
| Marc
|
|
|
| --
| Neu: GMX De-Mail - Einfach wie E-Mail, sicher wie ein Brief!
| Jetzt De-Mail-Adresse reservieren: http://portal.gmx.net/de/go/demail
| _______________________________________________
| 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
--
Dirk Eddelbuettel | edd at debian.org | http://dirk.eddelbuettel.com
More information about the Rcpp-devel
mailing list