LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   How to build statically linked binary with autoconf (https://www.linuxquestions.org/questions/linux-general-1/how-to-build-statically-linked-binary-with-autoconf-769088/)

The_Sven 11-14-2009 06:53 AM

How to build statically linked binary with autoconf
 
I want to build a statically linked version of Ogg Vorbis on Ubuntu 9.10.

The Ogg Vorbis build environment seems to run on autoconf. There is a configure script which will generate a Makefile. If I give the configure script the following options:

--enable-static
--disable-shared

then statically linking <almost> works. Almost = the binary is statically linked to all necessary Ogg libraries, but it's still dynamically linked to the C library !

sven@inspiron-6000:~$ ldd ./oggenc
linux-gate.so.1 => (0x00b09000)
libm.so.6 => /lib/tls/i686/cmov/libm.so.6 (0x00cef000)
libc.so.6 => /lib/tls/i686/cmov/libc.so.6 (0x0029b000)
/lib/ld-linux.so.2 (0x006a8000)

When I <manually> add -static to the gcc command-line which generates oggenc, it seems to work just fine:

sven@inspiron-6000:~$ ldd oggenc
not a dynamic executable

I must confess that I know absolutely nothing about autoconf - I'm a Windows person. Ok, so shoot me ! :)

How to I link statically without having to run the last step manually?

paulsm4 11-14-2009 11:52 PM

This should help:

http://people.redhat.com/drepper/no_static_linking.html

PS:
Most of the discussion applies equally to Windows :)

Valery Reznic 11-15-2009 09:31 AM

Quote:

Originally Posted by The_Sven (Post 3756815)
I want to build a statically linked version of Ogg Vorbis on Ubuntu 9.10.

The Ogg Vorbis build environment seems to run on autoconf. There is a configure script which will generate a Makefile. If I give the configure script the following options:

--enable-static
--disable-shared

then statically linking <almost> works. Almost = the binary is statically linked to all necessary Ogg libraries, but it's still dynamically linked to the C library !

sven@inspiron-6000:~$ ldd ./oggenc
linux-gate.so.1 => (0x00b09000)
libm.so.6 => /lib/tls/i686/cmov/libm.so.6 (0x00cef000)
libc.so.6 => /lib/tls/i686/cmov/libc.so.6 (0x0029b000)
/lib/ld-linux.so.2 (0x006a8000)

When I <manually> add -static to the gcc command-line which generates oggenc, it seems to work just fine:

sven@inspiron-6000:~$ ldd oggenc
not a dynamic executable

I must confess that I know absolutely nothing about autoconf - I'm a Windows person. Ok, so shoot me ! :)

How to I link statically without having to run the last step manually?

I can understand why you want make static link to Oggs libraries, but why you want it for libc/libm too ?


All times are GMT -5. The time now is 10:37 PM.