<div dir="ltr"><div class="" itemprop="text">

<p>Hi,</p><p>I posted this on stackoverflow as well (<a href="http://stackoverflow.com/questions/32979586/using-cmake-to-build-rinside-examples-segfault">http://stackoverflow.com/questions/32979586/using-cmake-to-build-rinside-examples-segfault</a>), but this is perhaps a better venue.<br></p><p>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:</p>

<p>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.</p>

<p>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.</p><p><span style="font-family:monospace,monospace"><code><br></span></p><p><span style="font-family:monospace,monospace"><code></code></span></p><p><span style="font-family:monospace,monospace">$ make<br>Scanning dependencies of target rinside_sample1<br>[100%] Building CXX object CMakeFiles/rinside_sample1.dir/home/thenoob/tmp/RInside/src_cmake/rinside_sample1.cpp.o<br>In file included from /statdev/ext/r/releases/3.1.2/lib64/R/library/Rcpp/include/RcppCommon.h:142:0,<br>                 from /statdev/ext/r/releases/3.1.2/lib64/R/library/Rcpp/include/Rcpp.h:27,<br>                 from /statdev/ext/r/releases/3.1.2/lib64/R/library/RInside/include/RInsideCommon.h:38,<br>                 from /statdev/ext/r/releases/3.1.2/lib64/R/library/RInside/include/RInside.h:26,<br>                 from /home/thenoob/tmp/RInside/src_cmake/rinside_sample1.cpp:10:<br>/statdev/ext/r/releases/3.1.2/lib64/R/library/Rcpp/include/Rcpp/Interrupt.h:52:21: warning: unused parameter ‘dummy’ [-Wunused-parameter]<br>         inline void checkInterruptFn(void *dummy) {<br>                     ^<br>In file included from /statdev/ext/r/releases/3.1.2/lib64/R/library/Rcpp/include/RcppCommon.h:162:0,<br>                 from /statdev/ext/r/releases/3.1.2/lib64/R/library/Rcpp/include/Rcpp.h:27,<br>                 from /statdev/ext/r/releases/3.1.2/lib64/R/library/RInside/include/RInsideCommon.h:38,<br>                 from /statdev/ext/r/releases/3.1.2/lib64/R/library/RInside/include/RInside.h:26,<br>                 from /home/thenoob/tmp/RInside/src_cmake/rinside_sample1.cpp:10:<br>/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]<br> inline void r_init_vector<VECSXP>(SEXP x){}<br>             ^<br>/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]<br> inline void r_init_vector<EXPRSXP>(SEXP x){}<br>             ^<br>/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]<br> inline void r_init_vector<STRSXP>(SEXP x){}<br>             ^<br>In file included from /statdev/ext/r/releases/3.1.2/lib64/R/library/Rcpp/include/Rcpp/macros/macros.h:55:0,<br>                 from /statdev/ext/r/releases/3.1.2/lib64/R/library/Rcpp/include/RcppCommon.h:31,<br>                 from /statdev/ext/r/releases/3.1.2/lib64/R/library/Rcpp/include/Rcpp.h:27,<br>                 from /statdev/ext/r/releases/3.1.2/lib64/R/library/RInside/include/RInsideCommon.h:38,<br>                 from /statdev/ext/r/releases/3.1.2/lib64/R/library/RInside/include/RInside.h:26,<br>                 from /home/thenoob/tmp/RInside/src_cmake/rinside_sample1.cpp:10:<br>/statdev/ext/r/releases/3.1.2/lib64/R/library/Rcpp/include/Rcpp/Module.h: In copy constructor ‘Rcpp::CppClass::CppClass(const Rcpp::CppClass&)’:<br>/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]<br>      RCPP_CTOR_ASSIGN(CppClass)<br>                       ^<br>/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’<br> __CLASS__( const __CLASS__& other ){                                           \<br> ^<br>/statdev/ext/r/releases/3.1.2/lib64/R/library/Rcpp/include/Rcpp/Module.h: In copy constructor ‘Rcpp::CppObject::CppObject(const Rcpp::CppObject&)’:<br>/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]<br>         RCPP_CTOR_ASSIGN(CppObject)<br>                          ^<br>/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’<br> __CLASS__( const __CLASS__& other ){                                           \<br> ^<br>Linking CXX executable rinside_sample1<br>[100%] Built target rinside_sample1<br><code></code></span></p><p><code><span style="font-family:monospace,monospace"></code></span><br></code></p><code>

</code><p><code></code></p>

<p>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.</p>

<p>Any pointers would be great.</p><p>Thanks!</p><p>G<br></p>
    </div></div>