On 22 May 2012 at 12:51, Michael Hannon wrote: | Dirk Eddelbuettel <e...@debian.org> wrote: | | > On 22 May 2012 at 01:04, Michael Hannon wrote: | >| Darren Cook <dar...@dcook.org> wrote: | >| | >| >> I've run into a problem with the RInside "hello world" > example. I can | >| >> not get it to compile on my system. The first of the many error | >| >> messages is: | >| >> | >| >> undefined reference to `RInside::RInside(int, char const* const*, | >bool) | >| > | >| > You are not telling g++ where to find the R libraries that you need to | >| > link with. | > | >Correct -- the RInside package comes with four example directories. | > | >And each of these four directories has a Makefile. The easiest to start with | >is | > | > examples/standard/Makefile | > | >as you can simply drop in a new file 'myhelloworld.cpp' (or any other name | >you choose) into this directory and say 'make myhelloworld' --- and the | >binary 'myhelloworld' will be created for you. | > | >It does this by querying R via Rscript to learn about | > | > headers and libraries for R | > | > headers and libraries for Rcpp | > | > headers and libraries for RInside | > | >and all six components are needed for compiling and linking. | | Hmm. Thanks, Dirk. That Makefile is downright spooky smart (and worth a | study in its own right).
:-) "make" as a language actually won the same ACM Software Systems Awards that John Chambers won for R (and which Smalltalk, Tcl/Tk, Netscape/The Web, ... won too). I have learned a few tricks over the years, but that Makefile is pretty standard (apart from the the 'list all .cpp and derive basenames from it). | I was unaware of the "RHOME" option for R and the | "shell" function in GNU make. Given that I had only one *.cpp file in the | directory, I got the binary to build simply by typing "make", but I did check | that "make <filename>" also appears to work. Yup. You need the latter to make the former (via implicit 'make all') work. Dirk -- Dirk Eddelbuettel | e...@debian.org | http://dirk.eddelbuettel.com _______________________________________________ Rcpp-devel mailing list Rcpp-devel@lists.r-forge.r-project.org https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel