[Rcpp-devel] Rcpp compile question

Henry Bee henry.bee at gmail.com
Mon Mar 21 06:09:47 CET 2011


Dirk, thanks for your quick response. Here's the command:

> src <- '
> + Rcpp::NumericVector xa(a);
> + Rcpp::NumericVector xb(b);
> + int n_xa = xa.size(), n_xb = xb.size();
> +
> + Rcpp::NumericVector xab(n_xa + n_xb - 1);
> + for (int i = 0; i < n_xa; i++)
> + for (int j = 0; j < n_xb; j++)
> + xab[i + j] += xa[i] * xb[j];
> + return xab;
> ' +
> > fun <- cxxfunction(
> + signature(a="numeric", b="numeric"),
> + src, plugin="Rcpp")


On Sun, Mar 20, 2011 at 8:30 PM, Dirk Eddelbuettel <edd at debian.org> wrote:

>
> Hi Henry,
>
> On 20 March 2011 at 20:11, Henry Bee wrote:
> | Hi Dirk,
> |
> | I've been developing with R for the past year and came across your
> wonderful
> | presentation slides on Rcpp a few months ago. I am now turning to your
> Rcpp
> | package to translate the slowest portion of my code to C/C++.
>
> Great, welcome aboard!
>
> | I am testing the first example provided on page 6 in
> | your Rcpp-introduction.pdf document. Unfortunately I am getting compile
> errors
> | (listed below). Could you provide some guidance?
>
> You showed the outcome, you did not show the exact command you ran. Could
> you
> post that as well, please?
>
> Dirk
>
> |
> | Kind regards,
> |
> | Henry
> |
> |
> |
> |     ERROR(s) during compilation: source code errors or compiler
> configuration
> |     errors!
> |     Program source:
> |       1:
> |       2: // includes from the plugin
> |       3:
> |       4: #include <Rcpp.h>
> |       5:
> |       6:
> |       7: #ifndef BEGIN_RCPP
> |       8: #define BEGIN_RCPP
> |       9: #endif
> |      10:
> |      11: #ifndef END_RCPP
> |      12: #define END_RCPP
> |      13: #endif
> |      14:
> |      15: using namespace Rcpp;
> |      16:
> |      17:
> |      18: // user includes
> |      19:
> |      20:
> |      21: // declarations
> |      22: extern "C" {
> |      23: SEXP file3665625e( SEXP a, SEXP b) ;
> |      24: }
> |      25:
> |      26: // definition
> |      27:
> |      28: SEXP file3665625e( SEXP a, SEXP b ){
> |      29: BEGIN_RCPP
> |      30:
> |      31:  Rcpp::NumericVector xa(a);
> |      32:  Rcpp::NumericVector xb(b);
> |      33:  int n_xa = xa.size(), n_xb = xb.size();
> |      34:
> |      35:  Rcpp::NumericVector xab(n_xa + n_xb - 1);
> |      36:  for (int i = 0; i < n_xa; i++)
> |      37:  for (int j = 0; j < n_xb; j++)
> |      38:  xab[i + j] += xa[i] * xb[j];
> |      39:  return xab;
> |      40:
> |      41: END_RCPP
> |      42: }
> |      43:
> |      44:
> |     Error in compileCode(f, code, language = language, verbose = verbose)
> :
> |       Compilation ERROR, function(s)/method(s) not created!
> |     In addition: Warning message:
> |     running command 'C:\PROGRA~1\R\R-212~1.2/bin/i386/R CMD SHLIB
> |     file3665625e.cpp 2> file3665625e.cpp.err.txt' had status 1
> |
> |
> |
> |
> |
> | ----------------------------------------------------------------------
> | _______________________________________________
> | Rcpp-devel mailing list
> | Rcpp-devel at lists.r-forge.r-project.org
> | https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel
>
> --
> Dirk Eddelbuettel | edd at debian.org | http://dirk.eddelbuettel.com
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.r-forge.r-project.org/pipermail/rcpp-devel/attachments/20110320/d2101395/attachment-0001.htm>


More information about the Rcpp-devel mailing list