0

I have a NASM assembly file that I have compiled using the command: nasm -felf64 -g -Fdwarf groundFloor.asm -o file.o where groundFloor.asm is my NASM file. Using ld file.o -o file gives me a undefined reference to 'scanf' error. Does anyone know how to fix this so that it results in a ELF executable?

Rogue
  • 1
  • 2
  • 2
    Please show us your code. It is likely that you'll have to link with the libc. Likely, addition changes are needed to guarantee a working binary. – fuz Apr 02 '23 at 18:45
  • 2
    Simple fix is to use `main` as entry point and use `gcc` for linking. – Jester Apr 02 '23 at 18:50
  • You didn't tell `ld` to link with libc, so it didn't. Like Jester says, if you're going to call libc functions, linking with `gcc` is normally better; writing a `main` instead of `_start` is the simple way. See also [Can't call C standard library function on 64-bit Linux from assembly (yasm) code](https://stackoverflow.com/q/52126328) – Peter Cordes Apr 02 '23 at 19:32

0 Answers0