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

Dirk Eddelbuettel edd at debian.org
Wed Oct 7 02:45:45 CEST 2015


On 6 October 2015 at 14:29, Gaurav Veda wrote:
| 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.

In general, please do not cross post. If you decide this is the better venue,
maybe delete the post on SO?
 
| 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.

That is all we support.  RInside ships with a Makefile (per directory !!) and
those are tested.  As you say, they also work.
 
| 2) Copy the same example along with the cmake folder in the RInside/examples/

The CMake build files were contributed by Peter Aberline.  We have no reason
to believe it should stopped to work. Maybe Peter will stop by this thread
and offer help, maybe he won't.

| 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>

[... snip ...]

Those look like harmless compiler warnings.

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

Your non-standard locations are the like source of trouble.
 
| Any pointers would be great.

You can try to study what happens with the Makefile, and try to to make the
CMake file do the same.

In general, try to remain with the assumptions, eg see the these lines at the
top of GNUmakefile:

## comment this out if you need a different version of R, 
## and set set R_HOME accordingly as an environment variable
R_HOME := 		$(shell R RHOME)


That would appear to apply to your situation.

Dirk

-- 
http://dirk.eddelbuettel.com | @eddelbuettel | edd at debian.org


More information about the Rcpp-devel mailing list