[R] Calling Windows DLL using .C; function name not known but in exports.

Alex van der Spek doorz at xs4all.nl
Fri Jan 20 16:05:20 CET 2012


First time ever that I try to call subroutines in a Win DLL using R. 
Have done this before using VBA and Python.

The C code's function argument list contains only double pointers 
(double *x). The function is declared void, the output value is one of 
the arguments.
C calling sequence is used.

When inspecting the exports of the DLL with dumpbin I can see that the 
function I need is exported under the name 'planckwR'.

Loading the DLL with dyn.load(dllpath). Works fine. getLoadedDLLs() 
shows info on the 'Planck.dll' that I made. So far so good.

Made a function i R like this:

Planckw<-function(Temp) {
     wavelength<-0.0
     .C('planckwR',as.double(Temp),as.double(wavelength))
     return(wavelength)
}

Calling this function, R complains the function 'planckwR' is not in the 
DLL.

This baffled me as I can see it in the exports table using dumpbin.

I use Visual C++ 97 compiler. Old but works. It does change the FPU 
control word, which I know it should not. Working on that one too. Any tips?

Any help much appreciated.
Alex van der Spek



More information about the R-help mailing list