Hi people. Newbie(ish) question.
I've got an EXE file and it compiles fine, but assembling brings up the following error:
Assembling: C:\ASM Stuff\ASM\EXE Export\Export.asm
Microsoft (R) Incremental Linker Version 5.12.8078
Copyright (C) Microsoft Corp 1992-1998. All rights reserved.
LINK : error LNK2001: unresolved external symbol _WinMainCRTStartup
Export.exe : fatal error LNK1120: 1 unresolved externals
Make error(s) occured.
Here's the code:
It's just a test file I'm working on using code I found in a post today. Just wondering why I'm getting the linker error. I've checked the FAQ and found nothing. A search on this site brought up one post
http://www.asmcommunity.net/board/index.php?topic=2523&highlight=unresolved+external+symbol+WinMainCRTStartup
but I couldn't see precisely what the answer was to that question.
Cheers.
I've got an EXE file and it compiles fine, but assembling brings up the following error:
Assembling: C:\ASM Stuff\ASM\EXE Export\Export.asm
Microsoft (R) Incremental Linker Version 5.12.8078
Copyright (C) Microsoft Corp 1992-1998. All rights reserved.
LINK : error LNK2001: unresolved external symbol _WinMainCRTStartup
Export.exe : fatal error LNK1120: 1 unresolved externals
Make error(s) occured.
Here's the code:
.486
.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
;
; Prototypes
;
WinMain proto :DWORD,:DWORD,:DWORD,:DWORD
.data
szBuffer db 256 dup(0)
.code
WinMain proc hInst:HINSTANCE,hPrevInst:HINSTANCE,CmdLine:LPSTR,CmdShow:DWORD
invoke GetModuleFileName,0,ADDR szBuffer, 256
OR EAX, EAX
JZ Finish ; Leave if something went wrong
Add EAX, OFFSET szBuffer ; Get a pointer to the buffer string
Dec EAX
Cmp BYTE PTR [EAX], "\"
Jne Finish
Mov BYTE PTR [EAX], 0
invoke MessageBox,0,EAX,0,MB_OK
Finish:
invoke ExitProcess, 0
WinMain endp
End
It's just a test file I'm working on using code I found in a post today. Just wondering why I'm getting the linker error. I've checked the FAQ and found nothing. A search on this site brought up one post
http://www.asmcommunity.net/board/index.php?topic=2523&highlight=unresolved+external+symbol+WinMainCRTStartup
but I couldn't see precisely what the answer was to that question.
Cheers.
"_WinMainCRTStartup"
Are you linking in the standard C++ libraries (or some other .obj) in to the exe?
Are you linking in the standard C++ libraries (or some other .obj) in to the exe?
You are missing "Foo" and "End foo".
Try this:
Try this:
.486
.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
;
; Prototypes
;
;WinMain proto :DWORD,:DWORD,:DWORD,:DWORD
.data
szBuffer db 256 dup(0)
.code
foo:
; WinMain proc hInst:HINSTANCE,hPrevInst:HINSTANCE,CmdLine:LPSTR,CmdShow:DWORD
invoke GetModuleFileName,0,ADDR szBuffer, 256
OR EAX, EAX
JZ Finish ; Leave if something went wrong
Add EAX, OFFSET szBuffer ; Get a pointer to the buffer string
Dec EAX
Cmp BYTE PTR [EAX], "\"
Jne Finish
Mov BYTE PTR [EAX], 0
invoke MessageBox,0,EAX,0,MB_OK
Finish:
invoke ExitProcess, 0
;WinMain endp
End foo
Hi again.
Cheers Bazik, that idea using a Foo label works. For rerference I wasn't linking to any C/C++ code, just using the default modules that came with the MASM setup.
Thanks. :)
Cheers Bazik, that idea using a Foo label works. For rerference I wasn't linking to any C/C++ code, just using the default modules that came with the MASM setup.
Thanks. :)
You are missing "Foo" and "End foo".
:tongue: :grin: :)
Most people would use something like start instead of foo, but as you can see, it doesn't matter.
:)
why are people always using foo? I don't understand. :)
foo:
foo PROC
void foo()
foo struct
foo MACRO
.....
???
foo:
foo PROC
void foo()
foo struct
foo MACRO
.....
???
why are people always using foo? I don't understand. :)
foo:
foo PROC
void foo()
foo struct
foo MACRO
.....
???
http://www.tuxedo.org/~esr/jargon/html/entry/foo.html
and
http://www.tuxedo.org/~esr/jargon/html/entry/metasyntactic-variable.html
I know, but why? is it a personal preference? or for formality sakes?
both? :)
anyway, doesn't matter... :)
never mind. :grin:
both? :)
anyway, doesn't matter... :)
never mind. :grin:
I know, but why? is it a personal preference? or for formality sakes?
both? :)
anyway, doesn't matter... :)
never mind. :grin:
You are talking foo, stryker...
LMAO!!! :grin:
nah...
he just left out the most important thing of a program entry point :grin:
cheers :grin:
he just left out the most important thing of a program entry point :grin:
start:
...
...
...
end start
cheers :grin:
It's probably tradition. My old boss used to use it for everything. He was MIT, old DEC computer programmer.
It's probably tradition. My old boss used to use it for everything. He was MIT, old DEC computer programmer.
oh I see :grin:
usually I just do like this
labelname:
nameoffunction PROC
macroname MACRO
....
still the same but foo is much shorter and saves us a few keystrokes and save us a couple of milliseconds of typing. :grin:
It's probably tradition. My old boss used to use it for everything. He was MIT, old DEC computer programmer.
oh I see :grin:
usually I just do like this
labelname:
nameoffunction PROC
macroname MACRO
....
still the same but foo is much shorter and saves us a few keystrokes, saves us a couple of milliseconds of typing, saves a few processor cycles (long explanation snipped)... :grin:
Since I dont use the simplified segments and stuff, I just found is easier to do this:
For some reason I have had problem even with the start directive, but this works every time.
.686
.MMX
.model flat,stdcall
option casemap:none
option dotname
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
[COLOR=red]public WinMainCRTStartup[/COLOR]
_TEXT SEGMENT
[COLOR=red]WinMainCRTStartup label dword[/COLOR]
align 4
invoke GetModuleHandle, NULL
mov hInstance,eax
invoke main,eax,NULL,SW_SHOWDEFAULT
invoke ExitProcess,eax
.
.
.
For some reason I have had problem even with the start directive, but this works every time.
the start directive, don't you mean the end directive? (Isn't it the end that says where the code begins?)
the start directive, don't you mean the end directive? (Isn't it the end that says where the code begins?)
Not really sure. I don't use start: and end start(?) anymore.
IIRC one can use some option (I think: /entry:label ) to specify entry point.
What I ment was that it's the "END label" that tells ml.exe that the entry is at "label", if it's not wrong.
As I read it now I see it's hard (almost impossible) to understand what I ment, sorry. :o
What I ment was that it's the "END label" that tells ml.exe that the entry is at "label", if it's not wrong.
As I read it now I see it's hard (almost impossible) to understand what I ment, sorry. :o