NASM - The Netwide Assembler
NASM Forum => Programming with NASM => Topic started by: mmk213 on June 27, 2017, 04:43:58 AM
-
hi, i am using slackware linux, i am trying to compile this basic program, but i cannot start the executable when i compile it, it has something to do with linking the sdl2 library but i am new to this, not sure how to procede
my file (sdl.asm) is:
section .text
extern SDL_Init
global _start
_start:
mov rdi, 0x20
call SDL_Init
xor eax, eax
add al, 0x3C
syscall
so i'm trying to compile this basic code with
nasm -f elf64 sdl.asm -o sdl.o
ld sdl.o -o sdl -lSDL2
but when i start the file i get
bash: ./sdl: No such file or directory
"file sdl" gets me:
sdl: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib/ld64.so.1, not stripped
-
hm, i managed to get it running, not really sure why though
ld -dynamic-linker /lib64/ld-linux-x86-64.so.2 -o sdl sdl.o -lSDL2
this gave me a working executable, but i dont know why is this ld-linux-x86-64.so.2 link option needed.. i wil marked it solved
-
32-bit ld does the same thing - the default dynamic linker does not exist. I don't know why. If you want to save some typing, "-I" is an alias for "-dynamic-linker". Good job figuring it out. That "no such file or directory" - when you can see it right there - is pretty confusing!
Best,
Frank