What is the proper way to load in a dynamically linked library (i.e., a
system.file("src", "my_file.so", package = "R_PACKAGE")
The standard way to do this, as described in Writing R Extensions, is:
NAMESPACEfile can contain one or more
useDynLibdirectives which allows shared objects that need to be loaded.* The directive
registers the shared object
foo** for loading with
library.dynam. Loading of registered object(s) occurs after the package code has been loaded and before running the load hook function. Packages that would only need a load hook function to load a shared object can use the
*NB: this will only be read in all versions of R if the package contains R code in a R directory.
**Note that this is the basename of the shared object, and the appropriate extension (.so or .dll) will be added.