I am trying to compile the examples in the standard examples repository of the RInside package. I have already tried running the Makefile that was already in the repository, didn't work. Until now I've run into several errors, some of which have been solved so far. The problem is that every time I solve an error one of two things happen, it appears a new error or an old one reappears. This is the code of the different makefiles with the respective error:
1)Makefile without the -L
all:
g++ -I/usr/share/R/include -I/home/manuel/R/x86_64-pc-linux-gnu-library/3.4/Rcpp/include -I/home/manuel/R/x86_64-pc-linux-gnu-library/3.4/RInside/include rinsidetest.cpp
as expected, applying make to this file returns errors about undefined references to RInside::'s
undefined reference to `RInside::RInside(int, char const* const*, bool, bool, bool)'
2)Makefile with the -L links
all:
g++ -I/usr/share/R/include -I/home/manuel/R/x86_64-pc-linux-gnu-library/3.4/Rcpp/include -I/home/manuel/R/x86_64-pc-linux-gnu-library/3.4/RInside/include -L/usr/lib/R/site-library/RInside/lib -L/home/manuel/R/x86_64-pc-linux-gnu-library/3.4/Rcpp/libs -lRInside -lRcpp -L/usr/lib/R/lib -lR -Wl,-rpath,/home/manuel/R/x86_64-pc-linux-gnu-library/3.4/Rcpp/libs -lRInside -Wl,-rpath,/home/manuel/R/x86_64-pc-linux-gnu-library/3.4/RInside/lib rinsidetest.cpp
The error was this:
/usr/bin/ld: cannot find -lRcpp
it turns out that the .so file in the libs repository was named Rcpp.so, so I renamed it as libRcpp.so and the error was gone.
3)After renaming Rcpp.so as libRcpp.so I applied make to the same makefile of point 2) and the errors were once again about undefined references to RInside:::
rinsidetest.cpp:(.text+0x100): undefined reference to `RInside::RInside(int, char const* const*, bool, bool, bool)
4)Applying make to the makefile that was already in the folder
make -f Makefile
the error (after changing R_LIBS_USER to
R_LIBS_USER := "/home/manuel/R/x86_64-pc-linux-gnu-library/3.4"
was:
fatal error: RInside.h: No such file or directory compilation terminated.
So far I've read more general questions about including headers in C++, and a couple of questions specifically about RInside, some of which were answered by Dirk Eddelbuettel, who wrote the package, but all of the answers were related to the use of the linkers -L<path>/include which I'm almost sure I'm using correctly.
This are some of the questions I've read until now:
http://lists.r-forge.r-project.org/pipermail/rcpp-devel/2012-May/003829.html
http://rcpp-devel.r-forge.r-project.narkive.com/A70U2nVw/problem-with-rinside-hello-world-example
I'm using Ubuntu 16.04 with R version 3.4.4. Any help will be appreciated!
I am not sure where you got lost but the basic idea is to just say this:
make cleanjust in case.make(which ismake all) or just one.and that still works---I use Debian/Ubuntu myself.
Here is do
make rinside_sample0to prove the point, and then run it:I indented this by hand, and I may have some local settings in
~/.R/Makevarswhich show up here -- that does not matter.What matters is that it works out of the box if you just leave it alone. If you change the setup and it breaks you get to solve a problem you didn't have to create in the first place.