[R] Can R (without GUI) be compiled with static linking?

Barry Rowlingson b.rowlingson at lancaster.ac.uk
Fri Jul 29 09:10:05 CEST 2011


On Thu, Jul 28, 2011 at 10:54 PM, Jonathan Callahan
<jonathan at mazamascience.com> wrote:

> One of their requirements (hard or soft?) is that each module in the
> framework be compiled with statically linked libraries into a standalone
> binary that can be run from the command line.
>
> But if they insist on only using modules that are stand-alone, statically
> linked binaries I will need answers to the following questions:
>
> 1) Are the distributed R binaries statically linked?
> 2) Is the R code that runs in batch mode statically linked? (i.e. Will it
> break depending upon what shared libraries are installed?)
> 3) Is it possible to create a statically linked R that can be run "in batch
> mode"?
> 4) If not, how much C (or python? ;-D) code do I have to write to get to the
> point of having a stand-alone binary that can follow the instructions in an
> R script?

 There's another thing that may bite you, or bite them, if they are
going to be sticklers for this. Many R packages (add-ons) include
compiled C code that gets into R not when R is compiled like static
libraries, not when the R binary is run like dynamic libraries, but
when the user first goes require(foo) to use the package. See the
'Writing R Extensions' for more.

 I have a vague memory of something called an ELF Statifier which will
inspect a dynamically linked binary and then go get all the bits from
the referenced libraries and make a statically-linked binary.

http://statifier.sourceforge.net/

 Might work for you, something similar may exist for Solaris.

 Personally, given that R can't do much anything without all its base
packages (ie the single /usr/local/bin/R.bin executable can't do
anything on its own) I can't see the point in a single static binary.
If the client is worried about library compatibility then build R with
dynamic linking and then make a lib directory somewhere and copy all
the libs the binary needs there. Then point your LD_LIBRARY_PATH there
before running R.

  What's your clients motivation for this?

Barry

[also, this is probably an R-devel question]



More information about the R-help mailing list