On 14 April 2011 at 03:56, didu wrote: | Hi all, | | I'm new to R and Rcpp, and I'm trying to learn Rcpp with the simplest code | possible. My goal is to be able to call R functions from C++.
Just to set the record straight here for purpose of the mailing list archive: the original poster had a severe misunderstanding of Rcpp (which is used to extend R with C++ code) and RInside (which is used to embed R in standalone C++ code). The four-liner below is nonsensical as posted, yet its authors is now on his merry way thanks to a discussion on the rcpp-devel list where this should been posted in the first place. Dirk | The code I'm trying to run is: | | | #include | #include | #include | #include | | int main(int argc, char* argv[]) | { | Rcpp::NumericVector v(1); | return 0; | } | | | It compiles and links fine. However, as soon as I run it, it segfaults. The | following is the gdb trace: | | <co(gdb) run | Starting program: /home/jingy/tmp/stl | [Thread debugging using libthread_db enabled] | | Program received signal SIGSEGV, Segmentation fault. | 0x00002aaaabb86d70 in ?? () from /usr/lib/libR.so | (gdb) up | #1 0x00002aaaabb8849b in Rf_allocVector () from /usr/lib/libR.so | (gdb) | #2 0x0000000000401618 in Vector (this=0x7fffffffd880, size=@0x7fffffffd89c) | at /usr/local/lib/R/site-library/Rcpp/include/Rcpp/vector/Vector.h:130 | 130 RObject::setSEXP( Rf_allocVector( RTYPE, size) ) ; | (gdb) | #3 0x0000000000401438 in main (argc=1, argv=0x7fffffffd998) at stl.cpp:8 | 8 Rcpp::NumericVector v(1); | (gdb) | Initial frame selected; you cannot go up.de> | | | I installed the following R packages using "dpkg -i" on my Ubuntu 9.04 amd | 64 OS: | | r-base-core_2.12.1-1karmic0_amd64.deb | r-base-core-dbg_2.12.1-1karmic0_amd64.deb | r-base-dev_2.12.1-1karmic0_all.deb | | i installed Rcpp_0.9.4.tar.gz using the command: | | R CMD INSTALL Rcpp_0.9.4.tar.gz | | Any help would be greatly appreciated. | | Thanks a lot. | | -D | | -- | View this message in context: http://r.789695.n4.nabble.com/Rcpp-segmentation-faults-on-the-simplest-code-tp3449290p3449290.html | Sent from the R help mailing list archive at Nabble.com. | | ______________________________________________ | R-help@r-project.org mailing list | https://stat.ethz.ch/mailman/listinfo/r-help | PLEASE do read the posting guide http://www.R-project.org/posting-guide.html | and provide commented, minimal, self-contained, reproducible code. -- Dirk Eddelbuettel | e...@debian.org | http://dirk.eddelbuettel.com ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.