R: Loading DLLs from Packages (original) (raw)
library.dynam {base} | R Documentation |
---|
Description
Load the specified file of compiled code if it has not been loaded already, or unloads it.
Usage
library.dynam(chname, package, lib.loc,
verbose = getOption("verbose"),
file.ext = .Platform$dynlib.ext, ...)
library.dynam.unload(chname, libpath,
verbose = getOption("verbose"),
file.ext = .Platform$dynlib.ext)
.dynLibs(new)
Arguments
chname | a character string naming a DLL (also known as a dynamic shared object or library) to load. |
---|---|
package | a character vector with the name of package. |
lib.loc | a character vector describing the location of Rlibrary trees to search through. |
libpath | the path to the loaded package whose DLL is to be unloaded. |
verbose | a logical value indicating whether an announcement is printed on the console before loading the DLL. The default value is taken from the verbose entry in the systemoptions. |
file.ext | the extension (including ‘.’ if used) to append to the file name to specify the library to be loaded. This defaults to the appropriate value for the operating system. |
... | additional arguments needed by some libraries that are passed to the call to dyn.load to control how the library and its dependencies are loaded. |
new | a list of "DLLInfo" objects corresponding to the DLLs loaded by packages. Can be missing. |
Details
See [dyn.load](../../base/help/dyn.load.html)
for what sort of objects these functions handle.
library.dynam
is designed to be used inside a package rather than at the command line, and should really only be used inside[.onLoad](../../base/help/.onLoad.html)
. The system-specific extension for DLLs (e.g., ‘.so’ or ‘.sl’ on Unix-alike systems, ‘.dll’ on Windows) should not be added.
library.dynam.unload
is designed for use in[.onUnload](../../base/help/.onUnload.html)
: it unloads the DLL and updates the value of.dynLibs()
.dynLibs
is used for getting (with no argument) or setting the DLLs which are currently loaded by packages (using library.dynam
).
Value
If chname
is not specified, library.dynam
returns an object of class "[DLLInfoList](../../base/help/DLLInfoList.html)"
corresponding to the DLLs loaded by packages.
If chname
is specified, an object of class"[DLLInfo](../../base/help/DLLInfo.html)"
that identifies the DLL and which can be used in future calls is returned invisibly. Note that the class"[DLLInfo](../../base/help/DLLInfo.html)"
has a method for $
which can be used to resolve native symbols within that DLL.
library.dynam.unload
invisibly returns an object of class"[DLLInfo](../../base/help/DLLInfo.html)"
identifying the DLL successfully unloaded.
.dynLibs
returns an object of class "[DLLInfoList](../../base/help/DLLInfoList.html)"
corresponding to its current value.
Warning
Do not use [dyn.unload](../../base/help/dyn.unload.html)
on a DLL loaded bylibrary.dynam
: use library.dynam.unload
to ensure that .dynLibs
gets updated. Otherwise a subsequent call tolibrary.dynam
will be told the object is already loaded.
Note that whether or not it is possible to unload a DLL and then reload a revised version of the same file is OS-dependent: see the ‘Value’ section of the help for [dyn.unload](../../base/help/dyn.unload.html)
.
References
Becker, R. A., Chambers, J. M. and Wilks, A. R. (1988)The New S Language. Wadsworth & Brooks/Cole.
See Also
[getLoadedDLLs](../../base/help/getLoadedDLLs.html)
for information on "DLLInfo"
and"DLLInfoList"
objects.
[.onLoad](../../base/help/.onLoad.html)
, [library](../../base/help/library.html)
,[dyn.load](../../base/help/dyn.load.html)
, [.packages](../../base/help/.packages.html)
,[.libPaths](../../base/help/.libPaths.html)
[SHLIB](../../utils/html/SHLIB.html)
for how to create suitable DLLs.
Examples
## Which DLLs were dynamically loaded by packages?
library.dynam()
## More on library.dynam.unload() :
require(nlme)
nlme:::.onUnload # shows library.dynam.unload() call
detach("package:nlme") # by default, unload=FALSE , so,
tail(library.dynam(), 2)# nlme still there
## How to unload the DLL ?
## Best is to unload the namespace, unloadNamespace("nlme")
## If we need to do it separately which should be exceptional:
pd.file <- attr(packageDescription("nlme"), "file")
library.dynam.unload("nlme", libpath = sub("/Meta.*", '', pd.file))
tail(library.dynam(), 2)# 'nlme' is gone now
unloadNamespace("nlme") # now gives warning
[Package _base_ version 4.6.0 Index]