Compile as static

Micah Elliott mde at micah.elliott.name
Thu Oct 6 12:31:50 EDT 2005


On Oct 06, tjue1 at sussex.ac.uk wrote:
> Has anyone had any luck with this? Im trying to compile python 2.4.2 on
> Slackware 10.1 into one large executable. One which contains everything
> required to run python (as static). So python doesn't look for
> dynamically shared objects like libpthread.so.0.
> 
> I have tried ./configure --disable-dynamic
>                          --enable-dynamic=NO
>                          --enable-static
> 
> However the executable size is always the same :/ Please assist.

ldd is your friend for seeing the dependencies.  I see what you mean,
though.  I'm no autoconf expert, but AFAICT this was not an intended
feature.  My attempted grok of the Makefile also supports this theory.
And I don't see any of the options you specified as being valid.  Using
"--disable-shared" also doesn't affect "python", but does appear to make
libpython static, but I think it is regardless.  You can force the issue
with:

   $ ../configure ...
   $ make LDFLAGS=-static
   $ ls -l ./python
   -rwxr-xr-x  1 mdelliot support 2888818 Oct  6 08:06 ./python
   $ ldd ./python
   not a dynamic executable

But this gives some import warnings, and running has some problems...

Then I found these, indicating that it is easy ;-)

http://groups.google.com/group/comp.lang.python/browse_frm/thread/9407982ad24b62ec/5018f9abebaa285a?lnk=st&q=build+python+static&rnum=3&hl=en#5018f9abebaa285a

http://groups.google.com/group/comp.lang.python/browse_frm/thread/1ac371489ed4040b/076580464204cd79?lnk=st&q=build+python+static&rnum=5&hl=en#076580464204cd79

http://groups.google.com/group/comp.lang.python/browse_frm/thread/c532cc6469e29488/c6fcc1afbd7c41b0?lnk=st&q=build+python+static&rnum=17&hl=en#c6fcc1afbd7c41b0

It might be nice to have an autoconf option to make this more obvious
for guys like us.  Maybe this is just a rare need.

-- 
Micah Elliott
<mde at micah.elliott.name>



More information about the Python-list mailing list