Skip to content

Static R Build

3 messages · Michael Yan, Daniel Cegiełka, Simon Urbanek

#
Hello,

I am trying to build a statically linked R linux binary that can be 
shipped around to different unknown linux environments without having to 
rely on its local shared libraries.  However, it seems like the 
configure flag

--enable-static

doesn't produce the desired effect.  How may I do this?

Thank you for your help,
Michael
#
I'm not sure, but this option applies to Rblas and Rlapack. If you
want R statically linked you need to add the "-static" to
CFLAGS/FFLAGS etc.

regards,
daniel


2011/11/4 Michael Yan <michael.yan at oicr.on.ca>:
#
On Nov 4, 2011, at 4:37 PM, Michael Yan wrote:

            
That flag has nothing to do with that - it governs how R library will be built, not what it links against.
Make sure you link against static libraries, but you must make sure they have PIC (if relevant for your platform). How you do that depends heavily on your system setup (and it gets really hard if you want to have things like Tcl/Tk,  ..). The easiest is to simply install static libraries only so the linker picks them up automatically. Alternatively, you can specify static libraries directly as files (remmebr that you'll need to inslude dependecies, though, since static libraries don't have dependency chain resolution). Also depending on your compiler and/or how far you want to go, you may want to use -static-libgcc and friends (but, again, you must make sure they are PIC since they will be used from shared objects: packages).

Alternative route is to put dependent shared objects into $R_HOME/lib - that's in fact by far the easiest.

Cheers,
Simon