When I assemble this code and link,

.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

include /masm32/macros/macros.asm


invoke MessageBox,NULL,CTXT("Hello"),CTXT("Title?"),MB_OK
invoke ExitProcess,0

I've got this error..

Microsoft (R) Incremental Linker Version 5.12.8078
Copyright (C) Microsoft Corp 1992-1998. All rights reserv

LINK32 : error LNK2001: unresolved external symbol _WinMa
main.exe : fatal error LNK1120: 1 unresolved externals

But I changed like this

invoke MessageBox,NULL,CTXT("Hello"),CTXT("Title?"),MB_OK
invoke ExitProcess,0
end start

The error is gone..
What I changed is just to have put label...

Why the error comes if we dont use label?
Posted on 2004-06-02 20:20:19 by johnny_d
If you don't specify a start label, the MS linker will pick a default start label. The default resides in one of the C/C++ startup modules. If the linker succeeds in finding a startup module, the startup module will attempt to call WinMain or main, depending on whether the linker's subsystem option is (default) /SUBSYSTEM:WINDOWS or /SUBSYSTEM:CONSOLE.
Posted on 2004-06-02 20:56:26 by tenkey
Pheraphs you are thinking that put .code is where you programm start, exactly in the point where you put before the label "start", but that is not true at all.

With one file, pheraphs you can assume that the start of the section code is where the programm start his execution.

When you have more than one object file to link, you will have diferent sections of .code in each one that will be merged, but if is that, how the linker can assume that you always pass the first section (where it will start) in the first object file to link, then for that the linker need know explicitely where in the entry point of a file, if there exist more than one entry point in diferent object files, then also it will launch a error.

Also end directive of masm say two thigs:

1) not assemble more far from this point

2) and optionally, a label to be marked as the entry point of this file and to be extern (or global?).

Then you can put

one proc ....
; some code

;other code

end empieza

;more code that will not be assembled


Also I dont know if end directive put the necesary instructions for the linker and when you change the name of the entry point, like in the above example for "empieza" it also will know that is not necessary search for the "default" symbol WinMain or main. I supose it do.

Have a nice day or night.
Posted on 2004-06-05 11:26:08 by rea
The default start label is WinMainCRTStartup.
It is what I use. It should be PUBLIC as well.
Posted on 2004-06-05 11:38:26 by bitRAKE
for console mode apps it's mainCRTStartup . Remember, public and C calling convention (and thus name decoration, prefixing a '_')
Posted on 2004-06-05 15:17:40 by f0dder