How to find the program interpreter that a Linux application requests 1


Recently we tried to execute an application and we got the following error:
-bash: ./main: No such file or directory
This error occurred because our application was trying to use an interpreter that was not available on that machine.
We used the readelf utility that displays information about ELF files (including the interpreter information) to resolve our issue.
Specifically we used readelf -l ./main which displays the information contained in the file’s segment headers, if it has any.
(You can replace the parameter -l with --program-headers or --segments, they are the same).

From the data that was produced we only needed the following line:

[Requesting program interpreter: /lib/ld-linux-armhf.so.3]
so we used grep to filter out all other lines and then cut and tr to get the data after the : character (second column) and then remove all spaces and the ] character from the result.
The full and final command we used was:
readelf -l ./main | grep 'Requesting' | cut -d':' -f2 | tr -d ' ]';

This post is also available in: Greek


Leave a Reply to George MichaelCancel reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

One thought on “How to find the program interpreter that a Linux application requests

  • George Michael

    Scenario:
    You have the correct interpreter installed but it does not have the name that the application expects it to have.

    Solution:
    You can fake an alias using a symbolic link.
    e.g.

    ln -s /lib/ld-2.14.1.so /lib/ld-linux-armhf.so.3

    “In computing, a symbolic link (also symlink or soft link) is the nickname for any file that contains a reference to another file or directory in the form of an absolute or relative path and that affects pathname resolution.”
    From: https://en.wikipedia.org/wiki/Symbolic_link