[Rcpp-devel] R.e. Is it C++ or Rcpp problem?

Christian Gunning xian at unm.edu
Fri Sep 23 12:41:59 CEST 2011

On Fri, Sep 23, 2011 at 3:00 AM,
<rcpp-devel-request at r-forge.wu-wien.ac.at> wrote:
> You don't need a makefile for the kind of minimal example you'll post to
> a mailing list, so:
>  1. Slap your code in a file called tmp.cpp.
>    (Don't forget header includes.)
>  2. Whiz to a shell, in that directory.
>  3. Dramatically type:
>    g++ tmp.cpp
>  4. If it compiles, rush to run it with:
>    ./a.out

Interesting point.  I guess I'm not sure what constitutes "your code", though.

A lot of the mailing list examples use inline, which has a nice
verbose=T option that shows the program source that includes all the
needed header defns, as well as the necessary function definition
wrappers that we often omit here.  It also shows all the necessary
switches for g++.

The issue I see is that R takes the place of main(), and g++ requires
a main() to successfully compile.  I tried a trivial example, and I
didn't have any luck compiling. Am I missing something here?

cxxfunction(signature(x='numeric'), 'NumericVector xx(x);', verbose=T,

## copy Program source to file, edit for sanity
## flags below taken from cxxfunction output

$ g++ -I/usr/share/R/include
-I"~/R/x86_64-pc-linux-gnu-library/2.12/Rcpp/include" tmp.cpp

A man, a plan, a cat, a ham, a yak, a yam, a hat, a canal – Panama!

More information about the Rcpp-devel mailing list