Building Python statically on linux

M

Micah Elliott

Are there instructions somewhere on how to build Python (on linux)
statically? This seems like a common thing to do want to do, but my
searching isn't turning up much. If it is common, it would be nice to
see a configure option like I've seen in other tools:

--enable-all-static Build completely static (standalone)
binaries.

I'm ./configure-ing with "--disable-shared" (because this must mean
"enable static", right?), and (based on some other posts here) tried
adding "*static*" near the top of Modules/Setup. I'd like to see ldd
tell me "not a dynamic executable", but alas, it's presently:

$ ldd /path/to/new/bin/python
libpthread.so.0 => /lib/tls/libpthread.so.0 (0x008e9000)
libdl.so.2 => /lib/libdl.so.2 (0x007f0000)
libutil.so.1 => /lib/libutil.so.1 (0x00df6000)
libm.so.6 => /lib/tls/libm.so.6 (0x007cb000)
libc.so.6 => /lib/tls/libc.so.6 (0x0069f000)
/lib/ld-linux.so.2 (0x00682000)

Do I just need to be passing something like LDFLAGS="-static ???" to
configure? I just tried that and got a bunch of "symbol rename"
warnings during the compilation, and then "make install" mysteriously
failed.

Thanks for any pointers.
 
C

Christian Heimes

Micah said:
I'm ./configure-ing with "--disable-shared" (because this must mean
"enable static", right?), and (based on some other posts here) tried
adding "*static*" near the top of Modules/Setup. I'd like to see ldd
tell me "not a dynamic executable", but alas, it's presently:

--disabled-shared is the default value. It does not mean that the Python
interpreter is a static linked executable. --enable-shared builds a
libpython??.so and --disable-shared links libpython into the python binary.

Christian
 
Z

Zentrader

I think you can just add -static to the gcc Flag line in the
makefile. "man gcc" should also be helpful but that is a pile of docs
to wade through.
 
M

Micah Elliott

I think you can just add -static to the gcc Flag line in the
makefile.

Doing that (or CFLAGS=-static, or LDFLAGS=-static, or other Makefile
tweaks) gets me linker errors. Sounds like there's not a simple
prescribed means to do this (that anyone has documented). So now I'm
open to hearing about other hacks people have done to get this to
work. (Hopefully a config weenie heard my plea for --enable-all-
static)
 
C

Christian Heimes

Micah said:
> Doing that (or CFLAGS=-static, or LDFLAGS=-static, or other Makefile
tweaks) gets me linker errors. Sounds like there's not a simple
prescribed means to do this (that anyone has documented). So now I'm
open to hearing about other hacks people have done to get this to
work. (Hopefully a config weenie heard my plea for --enable-all-
static)

Can you work on the topic and write a small howto for your wiki
(http://wiki.python.org/moin/)? You have to modify Modules/Setup.local,
too. Read Modules/Setup for more information.

Christian
 
C

Christian Heimes

Micah said:
> Doing that (or CFLAGS=-static, or LDFLAGS=-static, or other Makefile
tweaks) gets me linker errors. Sounds like there's not a simple
prescribed means to do this (that anyone has documented). So now I'm
open to hearing about other hacks people have done to get this to
work. (Hopefully a config weenie heard my plea for --enable-all-
static)

Can you work on the topic and write a small howto for your wiki
(http://wiki.python.org/moin/)? You have to modify Modules/Setup.local,
too. Read Modules/Setup for more information.

Christian
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top