[Rcpp-devel] Problem with RInside "hello world" example

Michael Hannon jm_hannon at yahoo.com
Tue May 22 09:29:43 CEST 2012


Greetings.  I'm trying to go through some of the examples in the notes from
Dirk's Rcpp Masterclass of 28 April 2011.  (I didn't take the class.  I just
found the notes on the Internet.  Please let me know if my use of them
violates some law or protocol.  In case it makes any difference, I'm not
making any money from this project.)

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)

I've appended the details.  I get the same error if I omit the reference to
the c++0x standard.  What am I missing?

Thanks,

-- Mike


$ g++ --version
g++ (GCC) 4.6.3 20120306 (Red Hat 4.6.3-2)
Copyright (C) 2011 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

$ cat RI-hw.cpp 

#include <RInside.h>              // embedded R via RInside

int main(int argc, char *argv[]) {

    RInside R(argc, argv);        // create embedded R inst.

    R["txt"] = "Hello, world!\n"; // assign  to 'txt' in R

    R.parseEvalQ("cat(txt)");     // eval string, ignore result

    exit(0);
}

$ cat Makefile 
RI-hw.exe: RI-hw.cpp
    g++ -std=c++0x                              \
            -o RI-hw.exe                            \
        -I/usr/lib64/R/library/RInside/include/ \
        -I/usr/lib64/R/library/Rcpp/include/    \
        -I/usr/include/R                        \
            RI-hw.cpp

$ make
g++ -std=c++0x                              \
            -o RI-hw.exe                            \
    -I/usr/lib64/R/library/RInside/include/ \
    -I/usr/lib64/R/library/Rcpp/include/    \
    -I/usr/include/R                        \
            RI-hw.cpp
/tmp/ccDoMFpi.o: In function `main':
RI-hw.cpp:(.text+0xbe): undefined reference to `RInside::RInside(int, char
const* const*, bool)'
RI-hw.cpp:(.text+0xf6): undefined reference to
`RInside::operator[](std::basic_string<char, std::char_traits<char>,
std::allocator<char> > const&)'
RI-hw.cpp:(.text+0x15f): undefined reference to
`RInside::parseEvalQ(std::basic_string<char, std::char_traits<char>,
std::allocator<char> > const&)'
RI-hw.cpp:(.text+0x1e0): undefined reference to `RInside::~RInside()'
/tmp/ccDoMFpi.o: In function `Rcpp::wrap(char const*)':
RI-hw.cpp:(.text._ZN4Rcpp4wrapEPKc[Rcpp::wrap(char const*)]+0x16): undefined
reference to `R_NilValue'
RI-hw.cpp:(.text._ZN4Rcpp4wrapEPKc[Rcpp::wrap(char const*)]+0x24): undefined
reference to `Rf_mkString'
/tmp/ccDoMFpi.o: In function `bool Rcpp::Environment::assign<char
[15]>(std::basic_string<char, std::char_traits<char>, std::allocator<char> >
const&, char const (&) [15]) const':
RI-hw.cpp:(.text._ZNK4Rcpp11Environment6assignIA15_cEEbRKSsRKT_[bool
Rcpp::Environment::assign<char [15]>(std::basic_string<char,
std::char_traits<char>, std::allocator<char> > const&, char const (&) [15])
const]+0x32): undefined reference to
`Rcpp::Environment::assign(std::basic_string<char, std::char_traits<char>,
std::allocator<char> > const&, SEXPREC*) const'
collect2: ld returned 1 exit status
make: *** [RI-hw.exe] Error 1


More information about the Rcpp-devel mailing list