[Rd] Borland C++ and [R] dyn.load() for windows

Prof Brian Ripley ripley at stats.ox.ac.uk
Wed Oct 26 23:20:57 CEST 2005


On Wed, 26 Oct 2005, huanyu zhou wrote:

> Hi,
> I compiled a C program file on Borland C++ 5.5 compiler to get one dll output
> (as instructed in the file readme.package).
> The C program file is just the example on page 31 of "writing R extensions":
>
> void convolve(double *a, int *na, double *b, int *nb, double *ab)
> {
> int i, j, nab = *na + *nb - 1;
> for(i = 0; i < nab; i++)
> ab[i] = 0.0;
> for(i = 0; i < *na; i++)
> for(j = 0; j < *nb; j++)
> ab[i + j] += a[i] * b[j];
> }

> I used
> "bcc32 -Ic:\Borland\bcc55\include -Lc:\Borland\bcc55\Lib -u- -6 -O2 -WDE
> c:\Borland\bcc55\convolve.c"
> to get "convolve.dll". It seemed fine.
>
> When I used dyn.load("C:\\Borland\\BCC55\\Bin\\convolve.dll") in R (Version
> 2.0.1 ), it seemed fine also, no warning or error messages. However, when I
> used is.loaded("convolve") to check if it was loaded, it showed "False".
>
> I am working on winXP.
>
> What could be the possible reason for that?

The usual reason is that no symbols are exported from the DLL: please use 
pedump -e to check.  I don't see any evidence that you asked for any to be 
and the example in README.packages uses __declspec(dllexport) in the 
original source.  You are advised to look up the reference given there for 
further details.

-- 
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-devel mailing list