Skip to content

StaticBuild

Jeff Squyres edited this page Sep 3, 2014 · 1 revision

Tell configure that we want a static lib and then tell make that we want fully-static programs:

$ ./configure --enable-static --disable-shared LDFLAGS="-static"
$ make LDFLAGS=-all-static

Even more simple but we're lucky that this works with GCC:

$ ./configure --enable-static --disable-shared LDFLAGS="--static"

The actual problem is that -static is interpreted by libtool as "build static objects" but it's ignored when linking final programs. Passing -all-static to libtool ends up passing -static to gcc so that final programs are fully statically linked. But we can't put -all-static in LDFLAGS at configure time because it would be used during GCC checks and break configure.

--static works because it's (by chance) ignored by libtool and not by gcc.

See also http://www.open-mpi.org/community/lists/devel/2011/08/9591.php.

Clone this wiki locally