[R] cdecl and stdcall

Prof Brian Ripley ripley at stats.ox.ac.uk
Wed Sep 21 17:33:13 CEST 2005


This really is the wrong list.  Please do read the posting guide as we do 
ask (before posting).  In so far as this is relevant to R at all, it is 
within the description of the R-devel list.

On Wed, 21 Sep 2005, Bogner, Konrad (LfU) wrote:

> I'm trying to load a dynamic link library and it seems to work 
> (is.loaded -> TRUE). When I run the function, which calls the .Fortran 
> subroutine, R crashes! I'v tried the same in S-Plus 2000 and it worked. 
> Therefore I suppose that the dll has been compiled with the stdcall 
> calling convention (and not cdecl).

Hmm.  Why do you suppose so?  In so far as I can recall S-PLUS 2000 (it is 
long obselete) it worked with cdecl (as it was built with Watcom 
compilers).  The rw-FAQ explains how to get debugging information on the 
crash, which could have many causes.

> But the problem is that I don't have access to the source code, I've 
> just the dll without any working import library. Maybe someone could be 
> so kind and send me an example how to write a wrapper? I've found one 
> example at the NAG's site 
> (http://www.nag.com/numeric/RunderWindows.asp), but it didn't work. At 
> http://www.cygwin.com/cygwin-ug-net/dll.html there is a description of 
> linking against dlls and how to create a def and an import libraray 
> file, but unfortunately my dll seems to be stripped, because I get the 
> error message "no symbols" after running the command "nm".

A DLL with no symbols would be of no use to anyone, but your confusion is 
that nm does not apply to DLLs.  You need to find out what the DLL is 
exporting, with what convention.  pedump and pexports are the usual Open 
Source tools to do so.  The convention is normally hidden in the real 
symbol name, e.g. foo at 8 is a stdcall entry point, but may be aliased to 
foo.

> I'm using R 2.1.0 (windows xp) and CYGWIN (gnu compilers,..)

Cygwin is not a platform we support for R.

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