ID EN
Foreign & C Interface

dyn.load

R Base 3.6.2

Load or unload DLLs (also known as shared objects), and test whether a C function or Fortran subroutine is available.

Syntax

R
dyn.load(x, local = TRUE, now = TRUE, ...)
dyn.unload(x)<p></p><p>is.loaded(symbol, PACKAGE = "", type = "")</p>

Arguments

Parameter Description
x a character string giving the pathname to a DLL, also known as a dynamic shared object. (See ‘Details’ for what these terms mean.)
local a logical value controlling whether the symbols in the DLL are stored in their own local table and not shared across DLLs, or added to the global symbol table. Whether this has any effect is system-dependent. It is ignored on Windows.
now a logical controlling whether all symbols are resolved (and relocated) immediately the library is loaded or deferred until they are used. This control is useful for developers testing whether a library is complete and has all the necessary symbols, and for users to ignore missing symbols. Whether this has any effect is system-dependent. It is ignored on Windows.
&#8230; other arguments for future expansion. See section ‘Windows’ below.
symbol a character string giving a symbol name.
PACKAGE if supplied, confine the search for the name to the DLL given by this argument (plus the conventional extension, .so, .sl, .dll, …). This is intended to add safety for packages, which can ensure by using this argument that no other package can override their external symbols. This is used in the same way as in .C, .Call, .Fortran and .External functions.
type The type of symbol to look for: can be any ("", the default), "Fortran", "Call" or "External".

Return Value

The function dyn.load is used for its side effect which links the specified DLL to the executing R image. Calls to .C, .Call, .Fortran and .External can then be used to execute compiled C functions or Fortran subroutines contained in the library. The return value of dyn.load is an object of class DLLInfo. See getLoadedDLLs for information about this class. The function dyn.unload unlinks the DLL. Note that unloading a DLL and then re-loading a DLL of the same name may or may not work: on Solaris

Details

The objects dyn.load loads are called ‘dynamically loadable libraries’ (abbreviated to ‘DLL’) on all platforms except macOS, which uses the term for a different sort of object. On Unix-alikes they are also called ‘dynamic shared objects’ (‘DSO’), or ‘shared objects’ for short. (The POSIX standards use ‘executable object file’, but no one else does.) See ‘See Also’ and the ‘Writing R Extensions’ and ‘R Installation and Administration’ manuals for how to create and install a suitable DLL. Unfortunately a very few platforms (e.g., Compaq Tru64) do not handle the PACKAGE argument correctly, and may incorrectly find symbols linked into R. The additional arguments to dyn.load mirror the different aspects of the mode argument to the dlopen() routine on POSIX systems. They are available so that us

Examples

Example
R
# NOT RUN {
## expect all of these to be false in R >= 3.0.0.
is.loaded("supsmu") # Fortran entry point in stats
is.loaded("supsmu", "stats", "Fortran")
is.loaded("PDF", type = "External") # pdf() device in grDevices
# }

See Also

library.dynam to be used inside a package's .onLoad initialization. SHLIB for how to create suitable DLLs. .C .Fortran .External .Call.