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

Martin Maechler maechler at stat.math.ethz.ch
Wed Apr 27 13:11:10 CEST 2005


>>>>> "accetta" == accetta  <accetta at virgilio.it>
>>>>>     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> "http://www.swarthmore.edu/NatSci/peverso1/TLNise/tlnise.htm".

    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




More information about the R-help mailing list