bug-parted
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: building a static binary


From: Alan Su
Subject: Re: building a static binary
Date: Wed, 10 Mar 2010 15:31:17 -0500

sorry for the reply-to-self...i was able to cobble together a static
binary by doing (roughly):

$ ./configure --disable-shared --disable-dynamic-loading
[...]
$ make
[...]
$ cd parted
$ gcc -static -std=gnu99 -DBUILDINFO= -g -O2 -Werror -o parted-static
parted-command.o parted-parted.o parted-strlist.o parted-ui.o
parted-table.o ../libparted/.libs/libparted.a /usr/lib/libreadline.a
/usr/lib/libncurses.a
../../LVM2.2.02.61/install/lib/libdevmapper.a.1.02 /usr/lib/libuuid.a

that nasty command line was constructed by (a) removing the
dynamically linked parted that was built by make, (b) executing 'make
-n' to get the list of object files and link-line order of libraries,
(c) adding the -static flag to gcc, and (d) incrementally adding
libraries as needed to the link line, based on undefined symbols
reported.  i can't help but think there's a better way to do this...i
would welcome any suggestions or reports of cleaner methods of
accomplishing this.

fwiw, that link command also emits a bunch of warnings from
libreadline along the lines of "Using 'endpwent' in statically linked
applications requires at runtime the shared libraries from the glibc
version used for linking" but the binary doesn't seem to be
problematic.  i get a warning-less link if i use this same method
after having configured with --without-readline.

thanks,

-alan

On Wed, Mar 10, 2010 at 1:55 PM, Alan Su <address@hidden> wrote:
> hi bug-parted,
>
> i am trying to build a completely static binary for parted (i've
> downloaded the source for v2.2), and i can't seem to achieve that.
> i've run ./configure with --disable-shared, but after running make, i
> get a binary that is still dynamically linked:
>
> $ file parted/parted
> parted/parted: ELF 64-bit LSB executable, x86-64, version 1 (SYSV),
> for GNU/Linux 2.6.8, dynamically linked (uses shared libs), not
> stripped
> $ ldd parted/parted
>        libuuid.so.1 => /lib/libuuid.so.1 (0x00002b5c80d71000)
>        libdevmapper.so.1.02 => not found
>        libreadline.so.5 => /lib/libreadline.so.5 (0x00002b5c80f75000)
>        libdl.so.2 => /lib/libdl.so.2 (0x00002b5c811b5000)
>        libncurses.so.5 => /lib/libncurses.so.5 (0x00002b5c813ba000)
>        libc.so.6 => /lib/libc.so.6 (0x00002b5c815f5000)
>        /lib64/ld-linux-x86-64.so.2 (0x00002b5c80b52000)
>
> anyone have any advice on how to do this?  i must be doing something
> incredibly brain-dead...
>
> -alan
>




reply via email to

[Prev in Thread] Current Thread [Next in Thread]