[R] building a Win32 DLL with R objects?

Prof Brian Ripley ripley at stats.ox.ac.uk
Wed May 21 00:08:16 CEST 2003


On Tue, 20 May 2003, Jeff D. Hamann wrote:

> I've been attemping to create a test dll that contains R objects (actually I
> simply copied the code from the "Writing R extensions") and got it to build
> the dll using rcmd shlib main.c (okay, it's simple, but effective). Here's
> the info so far:
>
> this is the contents of the main.c file (not there's no WinMain()). Do we
> put it in or does the script do it when we compile?

The linker does what is needed to build a DLL and with gcc/ld there is no 
need of a user-supplied WinMain.

[...]

> WHen I try to compile a project, similar to my other projects I've been
> calling from R, I get the following linker errors:
> 
> Linking...
> main.obj : error LNK2001: unresolved external symbol _Rf_unprotect
> main.obj : error LNK2001: unresolved external symbol _REAL
> main.obj : error LNK2001: unresolved external symbol _LENGTH
> main.obj : error LNK2001: unresolved external symbol _Rf_warning
> main.obj : error LNK2001: unresolved external symbol _Rf_protect
> main.obj : error LNK2001: unresolved external symbol _Rf_coerceVector
> Debug/rdll_test.dll : fatal error LNK1120: 6 unresolved externals
> Error executing link.exe.
> 
> rdll_test.dll - 7 error(s), 6 warning(s)
> 
> And I can't find the lib file I should be including. Is there one or am I
> barking up the wrong tree?

Did you actually make R.lib?  The info is in readme.packages.  If you did, 
you haven't added it to your project.

Note that as an Open Source project we do not actually support VC++, but 
there is information there on how to use it.

-- 
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