Menu

ld link problem - "No such file or directory"

2009-03-01
2013-06-04
  • Nobody/Anonymous

    Hi,

    When I link my binaries to dynamic libraries using ld than the link operation finishes successfully and the executable is there.
    But when I try to run it I get an error message saying:

    bash: ./my_executable: No such file or directory

    By searching on the net I have found some similar cases and they said that it was solved by using gcc or by specifying an other dynamic linker for ld.
    On my system this solved the problem:
    ld "-I/lib64/ld-2.9.so" ....

    But I do not understand why and what is happening.
    It would be nice if someone could give some information why the ld does not work for dynamic linking.

    Thanks,
    Csaba

     
    • Nobody/Anonymous

      Hi,

      I have the same Problem, my code looks like this:
      ------------------------------------------
      section .text

      extern printf
      global start

      start:
            push message
          call printf
         
          mov eax, 1
          mov ebx, 0
          int 80h

      section .data
      message:     db "output some text", 10, 0
      ----------------------------------------------------------

      asm & link commands: nasm -f elf -g test.asm && ld -o test test.o -lc

      my OS is openSuse 11.1 (32-Bit)

      couldn't solve this problem so far.

      Regards,
      Andreas Monsch

       
    • Nobody/Anonymous

      Me again,

      i tried to solve the problem with the same approach as Csaba and it seems to work.
      But i also don't fully understand the cause of the problem.

      P.S.
      the link and asm command looks now like this: nasm -f elf -g test.asm && ld -o test test.o -lc -I/lib/ld-2.9.so

      Regards,
      Andreas Monsch

       
    • Nobody/Anonymous

      Well... if I understand what I'm reading (maybe so, maybe not), this seems to be set in "configure.host" in the "ld" directory of your binutils source.

      If you don't want to mess with recompiling ld (understandably), you can observe what ld is looking for by default by observing your executable in a text editor - it's fairly early in the file. Mine says "/lib/ld-linux.so.1". The "correct" answer is "/lib/ld-linux.so.2" (set with the "-I" or "--dynamic-linker" switch). If "/lib/ld-2.9.so" works... whatever you've got is "right", I guess.

      This has been going on for quite a while. It might not be unreasonable to ask the binutils guys to "get it right". In the meantime, we use whatever workaround we can find, I guess...

      Best,
      Frank

       

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.