I'm on Ubuntu using nasm 2.14.02.
I'm trying to write a simple hello world program with nasm by pushing the variable onto the stack and then calling printf:
; Import c-lib printf
extern printf
; Define Message and Length
section .data:
msg: db "Hello People!", 0xA
msg_len equ $-msg
section .text:
global _start
_start:
push msg
call printf
mov eax, 1
mov ebx, 0
int 80h
Assembling the program with nasm works fine, but when I try to link it with ld it throws this error:
ld: hello_world.o: in function `_start':
hello_world.asm:(.text:+0x6): undefined reference to `printf'
So it seems extern does not import printf. What am I doing wrong. This is literally my first assembler program, so please use simple words.
Edit:
The commands I was using are:
nasm hello_world.asm -f elf64
ld hello_world.o -o hello_world