[R] Compiling C++ package source: linking problem?
Alet Roux
A.Roux at hull.ac.uk
Wed Jun 16 17:23:14 CEST 2004
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?
My PATH variable is as follows:
C:\R\tools;C:\Perl\bin\;C:\mingw\bin;c:\R\rw1090\bin;C:\Program
Files\MiKTeX\miktex\bin;...;C:\Program Files\HTML Help Workshop
I should mention that I'm a complete R and C++ newbie; any help would be
sincerely appreciated.
Regards
Alet
-------------------------------------
Alet Roux
Department of Mathematics
University of Hull
Kingston upon Hull
HU6 7RX
United Kingdom
URL: http://www.hull.ac.uk/php/mapar/
Tel: +44 (1482) 466463
Fax: +44 (1482) 466218
More information about the R-help
mailing list