[R] registration of C routines

Duncan Temple Lang duncan at research.bell-labs.com
Thu Jul 19 16:07:28 CEST 2001


Hi,,

  There are 3 different places you can find out more about the
registration mechanism. The place to find code examples
is in the libraries in the R distribution. For example, take a
look at
  src/library/ctest/src/init.c

Also, I have collected the descriptions (drafts) I have written
about this. They are available from
  http://cm.bell-labs.com/stat/duncan/R


The C routine R_FindSymbol() is the internal mechanism that finds a
native symbol by name in a package. It is not in the official API, so
is subject to change. Hence it is not a good idea to write your code
to depend on it, but your mileage may vary depending on the context,
etc.

Personally, I would think that it might be better to avoid this
low-level dependency. You might be better off linking the DLL/.so from
the secondary package with that in the first package.  Alternatively,
on some platforms, you can specify the value of the local argument as
FALSE for dyn.load() and library.dynam() and that makes the symbols in
that library visible to all the others. Then your C code can call the
routine directly. This has potential danger based on how dlopen()
works on each system and the order in which the libraries have been
loaded.


  D.


Setzer.Woodrow at epamail.epa.gov wrote:
> Almost at the end of the News for R-1.3.0 is the following section:
> 
> o   New mechanism for explicitly registering native routines in a
>      DLL/shared library accessible via .C(), .Call(), .Fortran() and
>      .External().  This is potentially more robust than the existing
>      dynamic lookup, since it checks the number of arguments, type of
>      the routine.
> 
> How do I learn how to use this mechanism?  Also, is there a sanctioned way
> to find and use, in C-code loaded via dyn.load and executed using one of
> the calls .C(), etc., functions defined in a separate DLL/shared library
> and also loaded with dyn.load?
> 
> R. Woodrow Setzer, Jr.                                            Phone:
> (919) 541-0128
> Experimental Toxicology Division                       Fax:  (919) 541-5394
> Pharmacokinetics Branch
> NHEERL MD-74; US EPA; RTP, NC 27711
> 
> -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
> r-help 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-help-request at stat.math.ethz.ch
> _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._

-- 
_______________________________________________________________

Duncan Temple Lang                duncan at research.bell-labs.com
Bell Labs, Lucent Technologies    office: (908)582-3217
700 Mountain Avenue, Room 2C-259  fax:    (908)582-3340
Murray Hill, NJ  07974-2070       
         http://cm.bell-labs.com/stat/duncan
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help 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-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list