[Rd] Bundling vendor library inside a package
Dirk Eddelbuettel
edd at debian.org
Sun Mar 9 15:36:24 CET 2014
On 6 March 2014 at 10:56, John Laing wrote:
| If I have a vendor library (say libvendor.so) that I want my package to
| link to, what is the "right way" to bundle that inside my package? My ideal
| outcome would be that the package can be installed from tarball without
| having to worry about installing anything to /usr/lib or tweaking some
| systemwide variables. This isn't for public distribution so I'm not worried
| about CRAN restrictions or licensing issues. I'm running R 3.0.2 on Linux.
|
| I've put the library in the inst directory of my package, and provided
| PKG_LIBS=-L../inst -lvendor. That works for compilation but then I need to
| provide LD_LIBRARY_PATH for R to find the library at runtime.
As it is a local package, you could use the 'rpath' directive to encode the
path to you vendor library in the shared library object which your package
creates.
>From http://tldp.org/HOWTO/Program-Library-HOWTO/shared-libraries.html
One link option you might use is ld's ``rpath'' option, which specifies
the runtime library search path of that particular program being
compiled. From gcc, you can invoke the rpath option by specifying it this
way:
-Wl,-rpath,$(DEFAULT_LIB_INSTALL_PATH)
If you use this option when building the library client program, you don't
need to bother with LD_LIBRARY_PATH (described next) other than to ensure
it's not conflicting, or using other techniques to hide the library.
It work as long as you never change the underlying path. Which is a fine
assumption as long you use the same R installation path -- which is quite
likely.
Dirk
--
Dirk Eddelbuettel | edd at debian.org | http://dirk.eddelbuettel.com
More information about the R-devel
mailing list