[R] Loading a dynamic library

Prof Brian Ripley ripley at stats.ox.ac.uk
Thu May 19 22:11:03 CEST 2005


On Thu, 19 May 2005, Astle, William J wrote:

> Hi,
>
> I'm trying to load a .dll library into R 2.1.0 on Windows using the
> "dyn.load" function.  The library is compiled with gcc 3.3.3 on cygwin
> 1.5.16.

Please use the correct OS's DLLs: Cygwin is another OS hosted on Windows. 
This might work, but it is not as good an idea as using the recommended 
compilers, or indeed any other Windows compiler.

> I compile and link:
>
> $ gcc -c myfile.cpp -o myfile.o [HRT]
> $ gcc -shared myfile.o -o myfile.dll [HRT]
>
> I then type, in the R console,
>
>> dynload("myfile.dll")[HRT]

What is `dynload', and what does [HRT] mean?

> And R hangs.

Are you sure?  It is more likely that your DLL's initialization code 
hangs.

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