Re: [R] dyn.load(), DLL, Fortran, TLNise software

From: Martin Maechler <>
Date: Wed 27 Apr 2005 - 21:11:10 EST

>>>>> "accetta" == accetta <>
>>>>> on Wed, 27 Apr 2005 11:55:56 +0200 writes:

    accetta> Dear all, I would like to call TLNise ("Two-Level
    accetta> Normal indipendent sampling estimation") software
    accetta> within R.

    accetta> This software estimates a hierarchical model and it
    accetta> can be download from Philip Everson's website at     accetta> "".

    accetta> The TLNise software consists of:

    accetta> 1) a Fortran source code (tlnisemv1.f) and 2) a     accetta> Splus code (TLNisemv1.src)

    accetta> To use this codes within R:

    accetta> 1) I compiled the source code using g77 (from
    accetta> MinGW).  I typed "g77 -c tlnisemv1.f" to create a
    accetta> Fortran object file (tlnisemv1.o).

    accetta> 2) I edited TLNisemv1.src to point to my copy of
    accetta> tlnise.o. I changed the path in     accetta> dyn.load("c:\\tlnisemv1.o")

(which was not ok, as you noticed later)

    accetta> 3) I modified the Splus code to be used in R (i.e I     accetta> changed _ with <-)

    accetta> 4) I sourced TLNisemv1.src into R using     accetta> source("c/TLNisemv1.src") to load the R functions.

    accetta> But when I tried to load the shared library using     accetta> the dyn.load() function I got an error message:

    accetta> Error in dyn.load(x, as.logical(local),
    accetta> as.logical(now)) : unable to load shared library
    accetta> "c:/programmi/wingw/programs/tlnisemv1.dll":

    accetta> So I decided to build a DLL from the source file     accetta> "tlnisemv1.f".

    accetta> For doing this, I first typed 
    accetta> "g77 --shared -o tlnisemv1.dll tlnisemv.f" using g77 (from MinGW).
    accetta> Then I edited TLNisemv1.src to point to my copy of
    accetta> "tlnisemv1.dll".

Here, you should have used something like

   Rcmd SHLIB tlnisemv.f

which probably calls g77 itself, but does so in way compatible with your version of R --- which is very important.

    accetta> But again when I tried to load the shared library
    accetta> using dyn.load() function I got the same error
    accetta> message.

    accetta> How can I debug this problem? How should I     accetta> proceed? Have you have used TLNise software in R?

    accetta> Thank you
    accetta> Gabriele Accetta mailing list PLEASE do read the posting guide! Received on Wed Apr 27 21:17:14 2005

This archive was generated by hypermail 2.1.8 : Fri 03 Mar 2006 - 03:31:27 EST