Jonathan Callahan
2011-Jul-28 21:54 UTC
[R] Can R (without GUI) be compiled with static linking?
I have a potential client that is considering R for data analysis and visualization modules within a larger framework. The host systems run either Solaris or a version of Linux. 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. I intend to recommend using R for many of their analytical components. I will recommend setting up a full R environment and packaging up new functionality for easy deployment. Then they can simply use R in batch mode: R --vanilla <xyz.r> xyz.out 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? Thanks in advance. Jon -- Jonathan Callahan, PhD Mazama Science 206-708-5028 mazamascience.com [[alternative HTML version deleted]]
Duncan Murdoch
2011-Jul-28 23:11 UTC
[R] Can R (without GUI) be compiled with static linking?
On 28/07/2011 5:54 PM, Jonathan Callahan wrote:> I have a potential client that is considering R for data analysis and > visualization modules within a larger framework. The host systems run either > Solaris or a version of Linux.Hopefully this client will respect the R license, and license their larger framework in a compatible way.> > 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. > > I intend to recommend using R for many of their analytical components. I > will recommend setting up a full R environment and packaging up new > functionality for easy deployment. Then they can simply use R in batch > mode: R --vanilla<xyz.r> xyz.out > > 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?I think this depends on the target platform, but clearly the answer is: just look at the one that interests you.> 2) Is the R code that runs in batch mode statically linked? (i.e. Will it > break depending upon what shared libraries are installed?)It will be the same as the rest of the install.> 3) Is it possible to create a statically linked R that can be run "in batch > mode"?I believe so.> 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?See the "Writing R Extensions" manual chapter on front ends. Duncan Murdoch
Barry Rowlingson
2011-Jul-29 07:10 UTC
[R] Can R (without GUI) be compiled with static linking?
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]