[R-pkg-devel] Debugging library.dynam to include a manual shared object

Georgi Boshnakov georg|@bo@hn@kov @end|ng |rom m@nche@ter@@c@uk
Wed Nov 18 14:05:03 CET 2020


> Building this works fine in RStudio with devtools::load_all('.'), but 
> | when I try to run R CMD INSTALL,...

Note that the devtools equivalents of 'R CMD build/check/install' are devtools::build(), devtools::check(), devtools::install().
devtools::load_all() has a different purpose. 

Georgi Boshnakov


-----Original Message-----
From: R-package-devel <r-package-devel-bounces using r-project.org> On Behalf Of Dirk Eddelbuettel
Sent: 18 November 2020 12:57
To: Jon Davidson <jondavidson47 using gmail.com>
Cc: r-package-devel using r-project.org
Subject: Re: [R-pkg-devel] Debugging library.dynam to include a manual shared object


Jon,

On 16 November 2020 at 12:27, Jon Davidson wrote:
| I am trying to build an R package with a manually compiled .so file. 
| To do so, I have included a call to useDynLib() in my NAMESPACE file.

In general you would not need to do that, or do that:

 - A package knows how to turn files in src/* into a .so (and a .dylib and a
   .dll none of which you need to explicitly, a huge win for you)

 - A package knows how to load a dynamic library declared in NAMESPACE
 
| Building this works fine in RStudio with devtools::load_all('.'), but 
| when I try to run R CMD INSTALL, I get the error: package or namespace 
| load failed in library.dynam(lib, package, package.lib): shared object 
| 'filename.so' not found.

Only `R CMD INSTALL` matters here for (scripted) CRAN operations. If that fails you have a problem, no matter how helpful the optional tools are.

| Is there any way I can debug library.dynam to see where it's looking 
| for my .so and why it can't find it? Thanks for your help!

As said, R knows where to find a package's shared library file. For the rest, it is (on Linux) ld.so and its documentation but you (as far as I can
remember) cannot set LD_LIBRARY_PATH from within a running R session.

It might help if you described your problem in more detail with a reproducible example.

Regards,  Dirk

--
https://dirk.eddelbuettel.com | @eddelbuettel | edd using debian.org

______________________________________________
R-package-devel using r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-package-devel



More information about the R-package-devel mailing list