I started learning assembly today and have ran many tests on linux that worked very well! I moved over to my PC and started to attempt to write some here. I ran into a problem when attempting to call external functions (which again, worked fine on linux) where I would get LINK 2001 Unresolved External errors telling me that WriteConsoleA is not defined when after compiling with nasm:
nasm -f win32 test.asm -o test.obj
and with cl.exe:
cl test.obj /link libcmt.lib kernel32.lib
I get these errors:
test.obj : error LNK2001: unresolved external symbol ExitProcess
test.obj : error LNK2001: unresolved external symbol GetStdHandle
test.obj : error LNK2001: unresolved external symbol WriteConsoleA
test.exe : fatal error LNK1120: 3 unresolved externals
The assembly:
extern ExitProcess, GetStdHandle, WriteConsoleA
NULL equ 0
STD_OUTPUT_HANDLE equ -11
section .data
msg db "Hello world!",0xa
msgLen equ $-msg
section .bss
dummy resd 1
section .text
global _main
_main:
push STD_OUTPUT_HANDLE
call GetStdHandle
push NULL
push dummy
push msgLen
push msg
push eax
call WriteConsoleA
push NULL
call ExitProcess
Copied almost exactly from here. Any help is much appreciated! Thanks!