• Forum
  • Lounge
  • MASM32 LNK2001 error, anyone know how to

 
MASM32 LNK2001 error, anyone know how to fix?

Hey when I try to compile a very basic program on windows 7 64bit with masm32 I get the following error :

hello.obj : error LNK2001: unresolved external symbol _printf
LINK : error LNK2001: unresolved eternal symbol _WinMainCRtStartup
hello.exe : fatal error LNK1120: 2 unresolved externals


Does anyone know how to fix this specific error?

my code is as follows :

1
2
3
4
5
6
7
8
9
10
11
12
.386
.model flat, c
.stack 100h
printf  PROTO   arg1:Ptr Byte
        .data
msg1    byte "Hello World!",0Ah,0
        .code
main    proc
        INVOKE printf, ADDR msg1
        ret
main    endp
        end


Thanks for reading.
It looks like you didn't include any libs for the linker. I'm not sure how masm32 handles this, but you'll need to include the files that define _printf.
_WinMainCRtStartup sounds like an entry point, so I feel like you left the entry point undefined. Look up how to define an entry point in masm32.
Also remember to take this advice with a grain of salt XD
I've done very little assembly, and it was under NASM.
Right on, I figured it was something with including (just by reading the errors) but unfortunately all the googling I have done has only turned up with links to invalid forum pages (MASM32 recently moved their message board I think which is why all the links are invalid).

I'll keep lookin - thanks again.
Topic archived. No new replies allowed.