From plummer@iarc.fr  Thu May 28 08:41:06 1998
From: plummer@iarc.fr (Martyn Plummer)
Date: Thu, 28 May 1998 07:41:06 -0000 ()
Subject: dependencies in .so files
In-Reply-To: <19980527185017.2030.qmail@sirio.stat.unipd.it>
Message-ID: <XFMail.980528075225.plummer@iarc.fr>

This modified version of b.c in Guido's example works for me (R-0.61.3,
RedHat Linux 5.0) without modifying the R source.  R keeps an internal
table of symbols which is accessible via the R_FindSymbol function
(defined in src/unix/dynload.c), so you can use this to return a
pointer to a function in a previously loaded library.

Pardon my C if I've done something stupid here.
Martyn.

--------------------------b.c--------------------------------
#include <stdio.h>

typedef int (*DL_FUNC) ();

DL_FUNC R_FindSymbol(char *);

void b(int *i) {
    char afun[] = "a";
    DL_FUNC fun;

    printf("in b.so; calling function a in a.so; i=%d\n",*i);
    fun = R_FindSymbol(afun);
    fun(i);
    printf("in b.so; now i=%d\n",*i);
}
---------------------------------------------------------------
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-devel mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-devel-request@stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._


dependencies in .so files
Martyn Plummer