[R] dynamic loading error with Open Watcom object file

Prof Brian Ripley ripley at stats.ox.ac.uk
Fri Feb 2 16:50:07 CET 2007


On Fri, 2 Feb 2007, Bill Shipley wrote:

> Hello.  I am trying to use a FORTRAN subroutine from within R (Windows
> version).  This fortran subroutine is compiled using the Open Watcom Fortran
> compiler and the compiled object file is called ritscale.obj.  Following the
> explanation on pages 193-194 of "The New S language" I use the dyn.load
> command:
>
>> dyn.load("f:/maxent/ritscale.obj")
> Error in dyn.load(x, as.logical(local), as.logical(now)) :
>        unable to load shared library 'f:/maxent/ritscale.obj':
>  LoadLibrary failure:  %1 n'est pas une application Win32 valide.
>
> The error message says:  LoadLibrary failure: %1 is not a valid Win32
> application
>
> I do not know what this means.  Can someone help?

Yes.

Unlike versions of S from the 1980s and 1990s, dyn.load() in R loads a DLL 
and not a compiled object.  As the help page says:

      dyn.load(x, local = TRUE, now = TRUE)

        x: a character string giving the pathname to a shared library or
           DLL.

'shared library' is a Unix name for what Windows calls a DLL.

So, you need to make a DLL from ritscale.obj.  I used to know how to do 
that under Watcom, but (S Programming p.245) 'it is fraught with 
difficulties'.  It would be much easier to use the recommended compiler 
(MinGW's g77).

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