Linking a C program directly with ld fails with undefined reference to `__libc_csu_fini`

后端 未结 8 1491
被撕碎了的回忆
被撕碎了的回忆 2020-11-30 08:54

I\'m trying to compile a C program under Linux. However, out of curiosity, I\'m trying to execute some steps by hand: I use:

  • the gcc frontend to produce assemb
8条回答
  •  半阙折子戏
    2020-11-30 09:34

    Take it:

        $ echo 'main(){puts("ok");}' > hello.c
        $ gcc -c hello.c -o hello.o
        
        $ ld hello.o -o hello.exe /usr/lib/crt1.o /usr/lib/crti.o /usr/lib/crtn.o \
    -dynamic-linker /lib/ld-linux.so.2 -lc
        
        $ ./hello.exe
        ok
    

    Path to /usr/lib/crt*.o will when glibc configured with --prefix=/usr

提交回复
热议问题