Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I installed an application [ e.g. fdisk ]. But it required libraries for execution. I am looking for utility/tool which will help me to create a static binary from already installed binaries. So that I can use it anywhere.

The only reliable tools that I found is ErmineLight from here , but this one is share-ware.

Is there any open-source software is available for the same ?

EDIT fdisk is just an example. I most of the time work on LFS, So If I have to use any utility, I need to follow the steps as

  1. Download the source
  2. configure
  3. make
  4. make test
  5. make install,

So just-to-save time, I am looking for a solution in which I will make a static binary from debian or from fedora or from other distrbution, try it on LFS, and If it works fine or as per my requirement, I will go with source-code for compilation.

share|improve this question
1  
is the goal just ease of transfer (i.e. put it on a usb, carry anywhere with that processor arch)? –  Mike Pennington May 2 '11 at 19:52

2 Answers 2

up vote 7 down vote accepted

If fdisk is just an example and your goal is really to make static executables from dynamic executables, try Elf statifier. There's even a comparison with Ermine (by the Ermine vendor, so caveat (non-)emptor). Note that

  • If you have many executables, their combined size is likely to be more than the combined size of the dynamically-linked executables plus the necessary dynamic libraries.
  • There are features of GNU libc that may not work in a statically-linked executables, such as NSS (databases of user names, host names, etc.) and locale-related features.

If your goal is to have a small, portable suite of system tools, you're looking for BusyBox, a suite of core tools intended for embedded systems (including fdisk). You may also be interested in a smaller standard library than Glibc, for example dietlibc or µClibc.

share|improve this answer
    
I tried Elf statifier, but to my surprise. It did not work. It segfaults. I tried many time with many distributions with many utilities. –  SHW May 3 '11 at 6:50
    
It probably segfaults for the address randomization: it's explained here: linux-magazine.com/Issues/2009/105/Ermine-vs.-Statifier –  Rmano Oct 15 at 17:48

Well... this looks like a very bad idea. But, it's possible.

As fdisk is open source, just grab its source, and look at the Makefile. You should find an option that will pass "-static" to gcc at compilation.

I'm not a C/C++ guru but as far as I know creating a statically-linked binary from an existing dynamically-linked binary is not possible.

If you want to use it anywhere, I'd recommend to use a tiny maintenance distribution that starts within seconds and let you modify everything.

It makes more sens to me because you'll probably want to modify the disk running your Linux/UNIX installation.

share|improve this answer
    
Your answer seems contradictory, you said "...very bad idea. But, it's possible", and then also "...creating a statically-linked binary from an existing dynamically-linked binary is not possible". Please clarify your answer, it would be be most helpful. –  TechZilla Jan 7 '12 at 2:38

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.