From maechler at stat.math.ethz.ch  Wed Jun 23 10:08:20 2004
From: maechler at stat.math.ethz.ch (Martin Maechler)
Date: Wed Jun 23 10:08:22 2004
Subject: [Rd] function not in load table
In-Reply-To: <40D863E3.1050209@izbi.uni-leipzig.de>
References: <40D863E3.1050209@izbi.uni-leipzig.de>
Message-ID: <16601.14964.360131.27461@gargle.gargle.HOWL>

>>>>> "Toralf" == Toralf Kirsten <tkirsten@izbi.uni-leipzig.de>
>>>>>     on Tue, 22 Jun 2004 18:52:51 +0200 writes:


    Toralf> I apologize for this often/old question. I found
    Toralf> some hints but couldn't solve the problem so far.

    Toralf> I have C functions (incl. the header files) as well

really C, not C++ ?
[or did you compile by a C++ compiler instead of C ?]
I ask because for C++ that's really a FAQ

    Toralf> as the R wrapper functions which I want to use for
    Toralf> faster calculations. These functions are included in
    Toralf> a R package.  The installation process seems to be
    Toralf> ok (no errors). I also can load the package without
    Toralf> errors. But when I call the function I got the
    Toralf> following error

    Toralf> wy.result <- wy.grps(data1=X1, grpdata=groups, nres=10000, 
    Toralf> alpha1=0.05, alpha2=0.05)
    Toralf> Error in .C("wy_grps_R", as.double(X), as.integer(n1), as.integer(n2),  :
    Toralf> C function name not in load table
    Toralf> Execution halted

this really means that there's no exported C function named 'wy_grps_R'
from the dyn.loaded C code.
Do
	nm -g  izbi.so
inside izbi/src/ in the shell to check.


    Toralf> The parameter are
    Toralf> data1 - result of read.table()
    Toralf> grpdata - dito
    Toralf> nres - integer
    Toralf> alpha1 nad alpha1 - factors (float)

    Toralf> In the R function wy.grps(...) the C function is called by using the 
    Toralf> statement

    Toralf> result <- .C("wy_grps_R",
    Toralf> as.double(X),
    Toralf> as.integer(n1),
    Toralf> as.integer(n2),
    Toralf> as.integer(p),
    Toralf> as.integer(unlist(grpidx)),
    Toralf> as.integer(grplen),
    Toralf> as.integer(grpnum),
    Toralf> as.character(WYFUN),
    Toralf> as.double(alpha2),
    Toralf> as.character(MINMAXFUN),
    Toralf> WYdist=double(nres),
    Toralf> as.integer(nres),
    Toralf> test.value=double(grpnum),
    Toralf> p.value=double(grpnum))

Vadim mentions that you should add  PACKAGE= "<pkgname>"  here
which is true but not related to your problem.

    Toralf> My .First.lib.R is as follows:
    Toralf> .First.lib <- function(libname, pkgname) {
    Toralf> library.dynam("izbi", package = pkgname, lib.loc = libname)
    Toralf> data(COLS, package=pkgname)
    Toralf> data(ROWS, package=pkgname)

    Toralf> if (exists(".Dyn.libs")) remove(".Dyn.libs")

not sure if the above is a good idea.
What do you want it for?

    Toralf> if (interactive() && getenv("DISPLAY") != "") x11()
    Toralf> }


    Toralf> I read something about R_CMethodDef in "Writing R
    Toralf> Extensions" but I'm not really sure where I should
    Toralf> write it, may in the .First.lib.R or in a separate
    Toralf> file?

That's something else nice -- but all happens on the C level.
For an example of this see in the R sources
  R-1.9.1/src/library/stats/src/init.c

Martin Maechler


[Rd] function not in load table
Martin Maechler