What libraries are needed for this binary to run?

11,667

Run file with the program as argument on the computer where ldd works. It will tell you if the binary is built for 32 or 64 bits. You probably have to install the 32 bit compatibility libraries before it will run, on debian/ubuntu this is called ia32-libs.

Share:
11,667
Hooked
Author by

Hooked

http://thoppe.github.io/ https://twitter.com/metasemantic

Updated on June 14, 2022

Comments

  • Hooked
    Hooked almost 2 years

    Linux-based (Ubuntu 11.10)

    Before my computer crashed I had a binary on my computer: ./program that was given to me without the source. This file executed just fine. When my hard drive failed, I started with a fresh install and tried to run this binary on the same computer. It now fails with:

    bash: ./program: cannot execute binary file
    

    Running ldd on the file gives a bit more information:

    /usr/bin/ldd: line 161: /lib64/ld-linux-x86-64.so.2: cannot execute binary file
    not a dynamic executable
    

    I have a second computer where the binary runs and ldd gives the output:

    ./program:
        linux-vdso.so.1 =>  (0x00007fffdad5e000)
        libz.so.1 => /lib64/libz.so.1 (0x00000039a1400000)
        libstdc++.so.6 => /usr/local/gcc/gcc-4.5.1/lib64/libstdc++.so.6 (0x00007fce82c7a000)
        libm.so.6 => /lib64/libm.so.6 (0x00007fce829f6000)
        libgcc_s.so.1 => /usr/local/gcc/gcc-4.5.1/lib64/libgcc_s.so.1 (0x00007fce827e1000)
        libc.so.6 => /lib64/libc.so.6 (0x00007fce82452000)
        /lib64/ld-linux-x86-64.so.2 (0x00007fce82f7f000)
    

    Is there a way I can tell what is needed so I can get my program running again? I know that anything installed before the crash was done with apt-get so I don't think it requires anything unique that's not in the repository.

    Localized question?

    I admit that this specific question may be particular to me - but the question still stands in the general sense. Given a binary only, how do you determine which libraries it needs to run?