Re: [Rd] Building R package with precompiled shared library

From: Simon Urbanek <>
Date: Wed, 14 Sep 2011 10:13:03 -0400

On Sep 14, 2011, at 9:52 AM, Paul Gilbert wrote:

> My understanding is that this cannot be done, for both licence and security reasons. The package build expects source code and removes binaries. You can link with binaries that are provided separately from the package, possibly coming from a vendor that sells non-open source code, but you cannot include them in the package. >

It is not quite true and it is not the reason for it failing ;). That reason is that libs is the wrong folder to put it in. Note that libs is the folder in the *installed* package that the shared object go to, not in the sources.

Also note that it is practically impossible to provide precompiled .so binaries (legal issues aside) because that would limit the package to one particular architecture and OS yet many R installations have at least two architectures. This also means that you would have to determine at build time where to put it ... (or relay on R installation mechanism but then you must make sure your binary is compatible with the currently built architecture).

In practice this is occasionally done for very specific systems - for example Windows: it can be quite hard to compile some (open source) dependencies on Windows so they can be shipped as static binaries (for both x64 and i386) and used by the build process. On all other systems the system libraries are used instead (for an example of this approach see "png" or "jpeg" packages on CRAN). But still, the shared object (here .dll) is not shipped, because that depends on the R version, so it is created from the static libraries by the R package building process instead.


> Paul

>> -----Original Message-----
>> From: [mailto:r-devel-bounces_at_r-
>>] On Behalf Of Francesco Finazzi
>> Sent: September 14, 2011 3:41 AM
>> To:
>> Subject: [Rd] Building R package with precompiled shared library
>> Dear R users,
>> we are trying to build a R package that includes a precompiled shared
>> library, let's say We created the skeleton of the package
>> and we moved the file into the libs folder that we created at
>> the same level of the folders man and R. Moreover we created the file
>> NAMESPACE and we added the line useDynLib(mylib, .registration=TRUE).
>> The building step seems to work correctly but when we try to install
>> the package we get
>> ** testing if installed package can be loaded
>> Error in library.dynam(lib, package, package.lib) :
>> shared library 'mylib' not found
>> we cannot understand what's wrong and where R searches for the
>> files.
>> Any suggestion?
>> Thanks,
>> Michela and Francesco
>> ______________________________________________
>> mailing list
> ====================================================================================
> La version française suit le texte anglais.
> ------------------------------------------------------------------------------------
> This email may contain privileged and/or confidential information, and the Bank of
> Canada does not waive any related rights. Any distribution, use, or copying of this
> email or the information it contains by other than the intended recipient is
> unauthorized. If you received this email in error please delete it immediately from
> your system and notify the sender promptly by email that you have done so. 
> ------------------------------------------------------------------------------------
> Le présent courriel peut contenir de l'information privilégiée ou confidentielle.
> La Banque du Canada ne renonce pas aux droits qui s'y rapportent. Toute diffusion,
> utilisation ou copie de ce courriel ou des renseignements qu'il contient par une
> personne autre que le ou les destinataires désignés est interdite. Si vous recevez
> ce courriel par erreur, veuillez le supprimer immédiatement et envoyer sans délai à
> l'expéditeur un message électronique pour l'aviser que vous avez éliminé de votre
> ordinateur toute copie du courriel reçu.
> ______________________________________________
> mailing list
> mailing list Received on Wed 14 Sep 2011 - 14:16:38 GMT

This quarter's messages: by month, or sorted: [ by date ] [ by thread ] [ by subject ] [ by author ]

All messages

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Wed 14 Sep 2011 - 15:50:30 GMT.

Mailing list information is available at Please read the posting guide before posting to the list.

list of date sections of archive