Open or Close a Shared Library DESCRIPTION: The dyn.open function makes shared libraries available for use by S-PLUS functions. The shared libraries with which S-PLUS is linked are available by default, without any action on your part, so you may not need to use this function to use symbols defined in "standard" libraries. Use dyn.close to close an open library that you have no further need for. USAGE: dyn.open(file, initialize="") dyn.close(file) REQUIRED ARGUMENTS: file character string giving an absolute or relative pathname of a shared library to open. OPTIONAL ARGUMENTS: initialize This argument is not currently supported. VALUE: character string giving the name of the opened or closed library. SIDE EFFECTS: for dyn.open, the requested library is opened and dynamically linked to the current S-PLUS session. For dyn.close, the requested library is closed. DETAILS: In most cases, the shared libraries you need (typically, an S-PLUS chapter's S.so file) is opened automatically when you attach the appropriate database. You will typically use dyn.open to open shared libraries that exist in unattached chapters or elsewhere on your system. Note that you may load only shared libraries and not archives (.a files). SEE ALSO: .Fortran (this gives information on both the .C and .Fortran functions. EXAMPLES: With the following C code, kept in the file mylog.c, % cat mylog.c # include "S_engine.h" # include void # if defined(__STDC__) mylog(double *x, long *n) # else mylog(x, n) double *x ; long *n ; # endif { long i ; if (*n < 0) { PROBLEM "n (=%ld) should not be negative", *n RECOVER(NULL_ENTRY) ; } for (i=0 ; i<*n ; i++) x[i] = log(x[i]) ; } we can make a shared library with the following UNIX commands: Splus CHAPTER mylog.c Splus make and once in S-PLUS can load it as follows: dyn.open("S.so") and use it with .C("mylog", c(45, 45*exp(1)), as.integer(2))[[1]] # [1] 3.806662 4.806662 If we want to change the C code, say to give the negative of the log, we must unload the shared object with dyn.close, edit the C code, use make again to make the shared library, then reload it using the dyn.open so that .C() will find the newly redefined function: dyn.close("S.so") !vi mylog.c !Splus make dyn.open("S.so") .C("mylog", c(45, 45*exp(1)), as.integer(2))[[1]] # [1] -3.806662 -4.806662