-1

I have a single 32bit executable binary file that I need to run on my x86_64 machine. If the file is executable (even dynamically linked), why do I need to install some dependencies related to the libraries of the programming language that the binary file programmed with?

[root@server]# file TcpServer
TcpServer: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.32, BuildID[sha1]=0x20fc1da672a6ba3632123abc654f9ea88b34259, not stripped

[root@server]# ./TcpServer</b>
 -bash: ./TcpServer: /lib/ld-linux.so.2: bad ELF interpreter: No such file or directory`

[root@server]# yum install glibc.i686
[root@server]# ./TcpServer
./TcpServer: error while loading shared libraries: libstdc++.so.6: cannot open shared object file: No such file or directory`
GChuf
  • 1,135
  • 1
  • 17
  • 28
IAmAliYousefi
  • 1,132
  • 3
  • 21
  • 33

3 Answers3

4

There may be several reasons why you need to install dependencies.

One reason is that when a dynamically linked (it's a misnomer because it hasn't been fully linked yet - it should be called "executable that needs dynamic linking") ELF is to be executed it's not really executed to start with, it got what's called a interpreter that will be executed. This interpreter is actually the dynamic linker that will do the actually linking. If the interpreter is missing or not a valid program the executable can't be executed (compare with a script where the shebang on the first line doesn't name a valid interpreter).

Another is that a dynamic linked when loading will need to be linked with certain dynamic libraries. This means of course that you need the dynamic libraries with which the executable is to be linked with.

A third reason may be that the executable uses files or other dependencies while it runs. For example it might need to invoke some other program, dynamically load libraries or even open files that it expects to be present.

From your result it looks like you've run into the two first problems.

skyking
  • 13,817
  • 1
  • 35
  • 57
3

The executable can use some dynamically linked libraries. This means the library is loaded at runtime. You can try to run your file (why not?), but you get a startup failure.

For more details see What do 'statically linked' and 'dynamically linked' mean?

Community
  • 1
  • 1
Lukáš Bednařík
  • 2,578
  • 2
  • 15
  • 30
2
  1. you attempt to run a 32-bit executable on a 64-bit system. That's why your initial run ended with "bad ELF interpreter".
  2. a typical Linux x86-64 system doesn't have 32-bit libraries installed so you need to provide them prior to run a 32-bit dynamically linked executable.

Try to use ldd <your binary> to see what libraries can not be found and install those libraries one by one.

user3159253
  • 16,836
  • 3
  • 30
  • 56