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

Dirk Eddelbuettel edd @end|ng |rom deb|@n@org
Wed Nov 18 13:57:28 CET 2020


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



More information about the R-package-devel mailing list