cannot find Scrt.o and crti.o

1.6k views Asked by At

I am trying to compile my assembly code

global main
extern printf

section .data
    msg db "Testing %i...", 0x0a, 0x00

section .text
main:
    push ebp
    mov ebp, esp
    push 123
    push msg
    call printf
    mov eax, 0
    mov esp, ebp
    pop ebp
    ret

using these commands:

$ nasm -f elf32 ex10.asm
$ gcc -m32 ex10.o ex10

but it gives me this error

/usr/bin/ld: cannot find Scrt1.o: No such file or directory
/usr/bin/ld: cannot find crti.o: No such file or directory
/usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-linux-gnu/11/libgcc.a when searching for -lgcc
/usr/bin/ld: cannot find -lgcc
/usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-linux-gnu/11/libgcc.a when searching for -lgcc
/usr/bin/ld: cannot find -lgcc
collect2: error: ld returned 1 exit status

Normal .c files work with gcc, but this one doesn't.

What should I do to fix this?

0

There are 0 answers