I'm compiling an asm file and I'm getting this one error but I don't know how to fix it. What causes this error to happen? When I try to "Build All" in MASM32 I get this error, and when I try to "Console Build All", I get "_MainCRTStartup". How do I fix this? Or just general information about this error, because the asm file is too large for me to post it here.
You will need to show us the code you are trying to build. It will need to have the correct entry point and be able to access any required libraries.
i think that's the error you get if you don't reference the entry point in the END statement
.CODE
main PROC
INVOKE ExitProcess,0
main ENDP
END main
I figured it out. I just added "_WinMainCRStartup" to the end of the code and it compiled successfully.
Hi Yollaguay,
No need to add _WinMainCRStartup to your code. Let me try to explain it with a quick example :
.386
.model flat,stdcall
option casemap:none
include \masm32\include\windows.inc
include \masm32\include\kernel32.inc
include \masm32\include\user32.inc
includelib \masm32\lib\kernel32.lib
includelib \masm32\lib\user32.lib
.data
message db 'Messagebox example',0
caption db 'Hello',0
.code
entry:
invoke MessageBox,0,ADDR message,ADDR caption,MB_OK
invoke ExitProcess,0
END
Building the project :
\masm32\bin\ml /c /coff MsgBox.asm
Microsoft (R) Macro Assembler Version 6.14.8444
Copyright (C) Microsoft Corp 1981-1997. All rights reserved.
Assembling: MsgBox.asm
***********
ASCII build
***********
\masm32\bin\polink /SUBSYSTEM:WINDOWS MsgBox.obj
POLINK: error: Unresolved external symbol '__WinMainCRTStartup'.
POLINK: fatal error: 1 unresolved external(s).
The linker complains because the entry point is missing. It should be defined just after the END statement :
.
.
.code
entry:
invoke MessageBox,0,ADDR message,ADDR caption,MB_OK
invoke ExitProcess,0
END entry
END entry tells to the linker that the entry point of the application is the label named entry. The traditional label to specify the entry point is named as start. You can select another one just like in the example above.
.code
start:
invoke MessageBox,0,ADDR message,ADDR caption,MB_OK
invoke ExitProcess,0
END start