[ RDocumentation ](/)

Moon  [ ](https://github.com/datacamp/rdocumentation-2.0) [ Learn R
](https://www.datacamp.com/learn/r)

Search all packages and functions

[ base  (version  3.6.2  ) ](/packages/base/versions/3.6.2)

#  library.dynam: Loading DLLs from Packages

##  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  R  library 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 system ` [ options ](/link/options?package=base&version=3.6.2) ` .

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 ](/link/dyn.load?package=base&version=3.6.2) ` 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.

##  Value

If ` chname ` is not specified, ` library.dynam ` returns an object of class `
" [ DLLInfoList ](/link/DLLInfoList?package=base&version=3.6.2) " `
corresponding to the DLLs loaded by packages.

If ` chname ` is specified, an object of class ` " [ DLLInfo
](/link/DLLInfo?package=base&version=3.6.2) " ` that identifies the DLL and
which can be used in future calls is returned invisibly. Note that the class `
" [ DLLInfo ](/link/DLLInfo?package=base&version=3.6.2) " ` 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
](/link/DLLInfo?package=base&version=3.6.2) " ` identifying the DLL
successfully unloaded.

` .dynLibs ` returns an object of class ` " [ DLLInfoList
](/link/DLLInfoList?package=base&version=3.6.2) " ` corresponding
corresponding to its current value.

##  Warning

Do not use ` [ dyn.unload ](/link/dyn.unload?package=base&version=3.6.2) ` on
a DLL loaded by ` library.dynam ` : use ` library.dynam.unload ` to ensure
that ` .dynLibs ` gets updated. Otherwise a subsequent call to ` library.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 ](/link/dyn.unload?package=base&version=3.6.2) ` .

##  Details

See ` [ dyn.load ](/link/dyn.load?package=base&version=3.6.2) ` 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
](/link/.onLoad?package=base&version=3.6.2) ` . The system-specific extension
for DLLs (e.g., ` .so ` or ` .sl ` on Unix-alike systems, ` .dll ` on Windows)
should not be added.

If ` … ` does not include a named argument ` DLLpath ` , ` [ dyn.load
](/link/dyn.load?package=base&version=3.6.2) ` is called with ` DLLpath ` set
to the package's ` libs ` directory. See the “Windows” section of the help on
` [ dyn.load ](/link/dyn.load?package=base&version=3.6.2) ` for how to control
where dependent DLLs are found.

See ` [ dyn.load