Skip to content

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

2 messages · huanyu zhou, Brian Ripley

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


thanks

huanyu
#
On Wed, 26 Oct 2005, huanyu zhou wrote:

            
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.