[R-pkg-devel] Using shared libraries

Dirk Eddelbuettel edd at debian.org
Sat Mar 31 06:42:30 CEST 2018


On 28 March 2018 at 19:47, Ogan Mancarci wrote:
| I have been looking for ways to use shared libraries in packages in CRAN
| and be able to write tests for them.

Well the basic problem here is that shared libraries are in fact provided by
the _operating system_ and hence you just introduced an OS dependency.
 
| When installing packages that depend on shared libraries, if a library is
| missing from the system we often get a nice error message complaining about
| the missing library during installation and listing what to install on

Really? If so it clearly is due to someone (maybe configure, maybe ad hoc
script) testing for such a requuired library.

| different linux builds, what to install on windows and mac. Similarly, how
| can I fail during installation if a required shared library is missing and
| show a warning to the users directing them to install it?

By writing a test.

| More importantly, if I want to write tests and examples for the package,
| how do I tell CRAN that it needs to have the shared library?

To a first approximation, if you need "foo" and CRAN does not have "foo" then
your package is borked, will not build, and hence get rejected.

Now, this was a brief email. There are A MILLION details we could discuss
here.

One possible example is nloptr:
- on windows, it required nlopt to be present, and to point to it via an
  environment library
- on systems with an X it tests, uses an system shared library if present,
  and if not downloads the sources
- at least that is what old versions did; the current -dev version switched
  to (AFAIK) either using system or using embedded sources.

In short, what you're after is the hardest possibly deployment path given the
cross-OS use of R.  No shortcuts.  But it is worth sorting this out.  A few
other packages, and this is the right list.

Dirk

-- 
http://dirk.eddelbuettel.com | @eddelbuettel | edd at debian.org



More information about the R-package-devel mailing list