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

Alex van der Spek doorz at xs4all.nl
Sun Jan 22 14:29:44 CET 2012


Thanks Duncan,

I will try gcc. In the mean time

is.loaded('planckwR',type='C') returns True

and

getNativeSymbolInfo('plankwR') returns that function name and a pointer 
to it plus some other info.

It seems the function is loaded? Why does the call .C('planckwR',...) 
not recognize it?

Alex van der Spek



On 01/22/2012 02:40 AM, Duncan Murdoch wrote:
> On 12-01-20 10:05 AM, Alex van der Spek wrote:
>> 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)
>> }
>
> That will return 0.0 once you get the name sorted out; .C won't modify 
> the variable wavelength, it will return new values in a list.
>
>>
>> Calling this function, R complains the function 'planckwR' is not in the
>> DLL.
>
> I would look in the export table printed by objdump -x to check this.  
> I don't know the dumpbin utility.
>>
>> 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?
>
> Use gcc?
>
> Duncan Murdoch
>
>>
>> Any help much appreciated.
>> Alex van der Spek
>>
>> ______________________________________________
>> R-help at r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide 
>> http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
>
>



More information about the R-help mailing list