[Rcpp-devel] Using cmake to build RInside examples (segfault)

Gaurav Veda vedagaurav at gmail.com
Tue Oct 6 23:29:42 CEST 2015


Hi,

I posted this on stackoverflow as well (
http://stackoverflow.com/questions/32979586/using-cmake-to-build-rinside-examples-segfault),
but this is perhaps a better venue.

I am trying to use RInside in an existing C++ project that uses cmake (on a
linux box). I don't understand cmake that well. I thought I'd get started
by getting an example RInside program to work with cmake. I tried 2 things:

1) Copy rinside_sample1.cpp from the RInside/examples/standard directory
along with its Makefile to a separate directory. Run make and then run the
executable. This works like a charm and produces the expected output.

2) Copy the same example along with the cmake folder in the
RInside/examples/standard directory to /home/thenoob/tmp/RInside/src_cmake.
Create a separate build directory /home/thenoob/tmp/RInside/build and run
cmake ../src_cmake/cmake . This runs without any error. Then run make. This
spits out a bunch of warnings, but builds the executable.

<code>

$ make
Scanning dependencies of target rinside_sample1
[100%] Building CXX object
CMakeFiles/rinside_sample1.dir/home/thenoob/tmp/RInside/src_cmake/rinside_sample1.cpp.o
In file included from
/statdev/ext/r/releases/3.1.2/lib64/R/library/Rcpp/include/RcppCommon.h:142:0,
                 from
/statdev/ext/r/releases/3.1.2/lib64/R/library/Rcpp/include/Rcpp.h:27,
                 from
/statdev/ext/r/releases/3.1.2/lib64/R/library/RInside/include/RInsideCommon.h:38,
                 from
/statdev/ext/r/releases/3.1.2/lib64/R/library/RInside/include/RInside.h:26,
                 from
/home/thenoob/tmp/RInside/src_cmake/rinside_sample1.cpp:10:
/statdev/ext/r/releases/3.1.2/lib64/R/library/Rcpp/include/Rcpp/Interrupt.h:52:21:
warning: unused parameter ‘dummy’ [-Wunused-parameter]
         inline void checkInterruptFn(void *dummy) {
                     ^
In file included from
/statdev/ext/r/releases/3.1.2/lib64/R/library/Rcpp/include/RcppCommon.h:162:0,
                 from
/statdev/ext/r/releases/3.1.2/lib64/R/library/Rcpp/include/Rcpp.h:27,
                 from
/statdev/ext/r/releases/3.1.2/lib64/R/library/RInside/include/RInsideCommon.h:38,
                 from
/statdev/ext/r/releases/3.1.2/lib64/R/library/RInside/include/RInside.h:26,
                 from
/home/thenoob/tmp/RInside/src_cmake/rinside_sample1.cpp:10:
/statdev/ext/r/releases/3.1.2/lib64/R/library/Rcpp/include/Rcpp/internal/r_vector.h:71:13:
warning: unused parameter ‘x’ [-Wunused-parameter]
 inline void r_init_vector<VECSXP>(SEXP x){}
             ^
/statdev/ext/r/releases/3.1.2/lib64/R/library/Rcpp/include/Rcpp/internal/r_vector.h:78:13:
warning: unused parameter ‘x’ [-Wunused-parameter]
 inline void r_init_vector<EXPRSXP>(SEXP x){}
             ^
/statdev/ext/r/releases/3.1.2/lib64/R/library/Rcpp/include/Rcpp/internal/r_vector.h:85:13:
warning: unused parameter ‘x’ [-Wunused-parameter]
 inline void r_init_vector<STRSXP>(SEXP x){}
             ^
In file included from
/statdev/ext/r/releases/3.1.2/lib64/R/library/Rcpp/include/Rcpp/macros/macros.h:55:0,
                 from
/statdev/ext/r/releases/3.1.2/lib64/R/library/Rcpp/include/RcppCommon.h:31,
                 from
/statdev/ext/r/releases/3.1.2/lib64/R/library/Rcpp/include/Rcpp.h:27,
                 from
/statdev/ext/r/releases/3.1.2/lib64/R/library/RInside/include/RInsideCommon.h:38,
                 from
/statdev/ext/r/releases/3.1.2/lib64/R/library/RInside/include/RInside.h:26,
                 from
/home/thenoob/tmp/RInside/src_cmake/rinside_sample1.cpp:10:
/statdev/ext/r/releases/3.1.2/lib64/R/library/Rcpp/include/Rcpp/Module.h:
In copy constructor ‘Rcpp::CppClass::CppClass(const Rcpp::CppClass&)’:
/statdev/ext/r/releases/3.1.2/lib64/R/library/Rcpp/include/Rcpp/Module.h:404:23:
warning: base class ‘class Rcpp::S4_Impl<Rcpp::PreserveStorage>’ should be
explicitly initialized in the copy constructor [-Wextra]
      RCPP_CTOR_ASSIGN(CppClass)
                       ^
/statdev/ext/r/releases/3.1.2/lib64/R/library/Rcpp/include/Rcpp/macros/interface.h:27:1:
note: in definition of macro ‘RCPP_CTOR_ASSIGN’
 __CLASS__( const __CLASS__& other
){                                           \
 ^
/statdev/ext/r/releases/3.1.2/lib64/R/library/Rcpp/include/Rcpp/Module.h:
In copy constructor ‘Rcpp::CppObject::CppObject(const Rcpp::CppObject&)’:
/statdev/ext/r/releases/3.1.2/lib64/R/library/Rcpp/include/Rcpp/Module.h:416:26:
warning: base class ‘class Rcpp::S4_Impl<Rcpp::PreserveStorage>’ should be
explicitly initialized in the copy constructor [-Wextra]
         RCPP_CTOR_ASSIGN(CppObject)
                          ^
/statdev/ext/r/releases/3.1.2/lib64/R/library/Rcpp/include/Rcpp/macros/interface.h:27:1:
note: in definition of macro ‘RCPP_CTOR_ASSIGN’
 __CLASS__( const __CLASS__& other
){                                           \
 ^
Linking CXX executable rinside_sample1
[100%] Built target rinside_sample1

</code>

However, as soon as I run the executable, it throws a segmentation fault. I
should mention that my R_HOME variable is not set and my LD_LIBRARY_PATH
contains
/statdev/ext/r/current/lib64/R/lib:/statdev/ext/r/current/lib64/R/library/RInside/lib.

Any pointers would be great.

Thanks!

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


More information about the Rcpp-devel mailing list