When I try to use the InitWindow function from raylib using this code:
global _main
extern InitWindow
extern _ExitProcess@4
section .data
title db "Window Title",0
section .text
_main:
push title
push 600
push 800
call InitWindow
add esp, 12
push 0
call _ExitProcess@4
and compiling with these commands:
nasm -f win32 example.asm -o example.o
gcc example.o -o example.exe -lraylib -lopengl32 -lgdi32 -lwinmm
it's always giving me this error:
example.o:example.asm:(.text+0x10): undefined reference to `InitWindow'
collect2.exe: error: ld returned 1 exit status
Same happens when I try to use other functions of the raylib lib.
I also tried editing the function name to this _InitWindow@12 or this _InitWindow but that didnt work either. I also tried to link the object file with the direct path to the raylib directory but that didnt work too.
_InitWindowto work, assuming of course that-lraylibfinds a 32-bit library. I think you'd get other errors if your GCC defaulted to-m64, so I'm assuming its Mingw32 GCC or something with-m32as the default. (Since that's necessary fornasm -f win32).nmon the library show, in terms of the symbols it defines? 32-bit x86 on Windows always decorates symbols with a leading_, so it's either_InitWindowif cdecl (like how you're calling it with anadd esp, 12after: caller pops), or_InitWindow@12if it's stdcall (caller pops, returning withret 12, number of arg bytes indicated with@12so ABI mismatch is a link error rather than stack corruption. In this case you shouldn'tadd esp,12after.)InitWindow. And/or look at C compiler output for a simple C program that calls these functions and exits. It's possible that some "functions" are actually macros or inline wrappers, or these's something else going on.