[R] Compiling C++ package source: linking problem?
Prof Brian Ripley
ripley at stats.ox.ac.uk
Wed Jun 16 17:58:34 CEST 2004
On Wed, 16 Jun 2004, Alet Roux wrote:
> Dear All
>
> I'm currently developing a package for R (1.9.0) on Win32, with C++ source code.
> Having followed the instructions in readme.packages, my code compiles fine with
> R CMD SHLIB (as well as R CMD check) ... until I start using the internal R
> functions.
>
> (Interesting: Rprintf seems to be the exception.) For instance, the following
> code compiles fine:
>
> #include <R.h>
> #include <Rdefines.h>
> ...
> SEXP whatever (SEXP model)
> {
> Rprintf ("Hello, here I am!\n");
> return model;
> }
>
> However, the following doesn't compile at all:
>
> #include <R.h>
> #include <Rdefines.h>
> ...
> SEXP whatever (SEXP model)
> {
> SEXP anotherModel;
> PROTECT(anotherModel = NEW_NUMERIC(4));
> UNPROTECT(1);
> return anotherModel;
> }
>
> An example of compiler feedback from R CMD SHLIB (I have mingw 3.1.0):
> ...: undefined reference to 'Rf_allocVector(unsigned,int)'
> ...: undefined reference to 'Rf_protect(SEXPREC*)'
> ...: undefined reference to 'Rf_unprotect(int)'
>
> Can anybody tell me what the matter is? Did I miss something?
Are you linking against the R.dll via its import library libR.a? Did the
latter get made correctly? That is where those entry points are.
More complete compiler output would have helped here.
--
Brian D. Ripley, ripley at stats.ox.ac.uk
Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/
University of Oxford, Tel: +44 1865 272861 (self)
1 South Parks Road, +44 1865 272866 (PA)
Oxford OX1 3TG, UK Fax: +44 1865 272595
More information about the R-help
mailing list