“No such file or directory” error when executing a binary

前端 未结 8 688
走了就别回头了
走了就别回头了 2020-11-28 01:15

I was installing a binary Linux application on Ubuntu 9.10 x86_64. The app shipped with an old version of gzip (1.2.4), that was compiled for a much older kernel:

         


        
相关标签:
8条回答
  • 2020-11-28 01:42

    Well another possible cause of this can be simple line break at end of each line and shebang line If you have been coding in windows IDE its possible that windows has added its own line break at the end of each line and when you try to run it on linux the line break cause problems

    0 讨论(0)
  • 2020-11-28 01:47

    I also had problems because my program interpreter was /lib/ld-linux.so.2 however it was on an embedded device, so I solved the problem by asking gcc to use ls-uClibc instead as follows:

    -Wl,--dynamic-linker=/lib/ld-uClibc.so.0
    
    0 讨论(0)
  • 2020-11-28 01:51

    It is possible that the executable is statically linked and that is why ldd gzip does not see any links - because it isn't. I don't know much about things that far back so I don't know if there would be incompatibilities if libraries are linked in statically. I might expect there to be.

    I know it's the most obvious thing going and I'm sure you've done it, but chmod +x ./gzip, yes? No such file or directory is a classic symptom of that not being done, that's why I mention it.

    0 讨论(0)
  • 2020-11-28 01:55

    readelf -a xxx

     INTERP         
      0x0000000000000238 0x0000000000400238 0x0000000000400238           
      0x000000000000001c 0x000000000000001c  R      1
      [Requesting program interpreter: /lib64/ld-linux-x86-64.so.2]
    
    0 讨论(0)
  • 2020-11-28 01:57

    The answer is in this line of the output of readelf -a in the original question

      [Requesting program interpreter: /lib/ld-linux.so.2]
    

    I was missing the /lib/ld-linux.so.2 file, which is needed to run 32-bit apps. The Ubuntu package that has this file is libc6-i386.

    0 讨论(0)
  • 2020-11-28 01:59

    Old question, but hopefully this'll help someone else.

    In my case I was using a toolchain on Ubuntu 12.04 that was built on Ubuntu 10.04 (requires GCC 4.1 to build). As most of the libraries have moved to multiarch dirs, it couldn't find ld.so. So, make a symlink for it.

    Check required path:

    $ readelf -a arm-linux-gnueabi-gcc | grep interpreter:
          [Requesting program interpreter: /lib/ld-linux-x86-64.so.2]

    Create symlink:

    $ sudo ln -s /lib/x86_64-linux-gnu/ld-linux-x86-64.so.2 /lib/ld-linux-x86-64.so.2

    If you're on 32bit, it'll be i386-linux-gnu and not x86_64-linux-gnu.

    0 讨论(0)
提交回复
热议问题