13

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.

  • 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
14

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.

  • 1
    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
  • 1
    It probably segfaults for the address randomization: it's explained here: linux-magazine.com/Issues/2009/105/Ermine-vs.-Statifier – Rmano Oct 15 '14 at 17:48
0

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.

  • 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. – J. M. Becker Jan 7 '12 at 2:38
  • @TechZilla: creating a static binary is possible, just not, per tiktak, creating one from an extant dynamically-linked binary. However, see the accepted answer for some possible abilities to do the latter. [Note: Comment intended more for future readers than to criticize anything that's here.] – lindes Sep 23 '15 at 0:58
-3

you can also use ELFex Linker, its a pretty cool program i just discovered, its gui and can create static executables from the dynamic executable.

  • the link doesn not work. – Jakuje Aug 27 '15 at 18:49
  • Link works for me and seems to answer the question directly. I'd suggest it's not spam. – roaima Aug 27 '15 at 22:27
  • The link works for me.  The page has the number of typos/grammatical/editorial errors that you might expect from the work of a professional programmer — more than you'd expect from a professional website, fewer than you'd expect from a phishing email.  About the same as the above post, come to think of it.  It seems suspicious that this brand new user would join Stack Exchange just in time to post a link to what appears to be a brand new web site. – G-Man Aug 27 '15 at 22:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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