Shared library not loaded into R binary package assembly

I'm trying to create a package with the compiled code C

in R

using 'RStudio' and 'devtools' in the Windows environment.

Only one of the functions uses the code C

in the folder src

. The original package works fine. I can use all functions. I can compile the C code with devtools::document()

, and the corresponding file .dll

and .o

also appear in the folder src

. Then I can load the code with dev_tools::load_all

or Ctrl+Shift+L

and run all functions.

However, when I build and reload the package with Ctrl+Shift+B

, I cannot use the specific function. The function is missing in the package, I even thought the documentation was saved. I also get an error stating that the corresponding one was .dll

not loaded.

Error in library.dynam.unload(name, system.file(package = name)) : 
  DLL ‘mypackage.dll’ was not loaded

      

I get the same results when I use devtools::build

with binary=TRUE

.

However, I can find the file .dll

in the library Documents\R\win-library\3.0\mypackage\libs\i386\mypackage.dll

. Why is this dynamic library not loaded from the compiled code?

PS: 1) devtools::has_devel()

gives TRUE

  2) I have to use .C

instead .Call

.

This is the result R CMD INSTALL

* installing to library 'C:/Users/lenovo/Documents/R/win-library/3.0'
* installing *source* package 'mypackage' ...
** libs
make: Nothing to be done for `all'.
installing to C:/Users/lenovo/Documents/R/win-library/3.0/mypackage/libs/i386
** R
** preparing package for lazy loading
** help
*** installing help indices
** building package indices
** testing if installed package can be loaded
* DONE (mypackage)

      

+3


source to share





All Articles