我正試圖用Masm32組裝一個簡單的「Hello world」應用程序。它裝配精細,但當我嘗試鏈接,鏈接器說無法解析的外部符號_WinMainCRTStartup
LINK:錯誤LNK2001:解析外部符號_WinMainCRTStartup prog1.exe:致命錯誤LNK1120:1周無法解析的外部
這是該程序的源代碼:
.586P
.MODEL FLAT, STDCALL
STD_OUTPUT_HANDLE equ -11
; Prototypes of external procedures
EXTERN [email protected]:NEAR
EXTERN [email protected]:NEAR
EXTERN [email protected]:NEAR
; INCLUDELIB directives for the linker
includelib c:\masm32\lib\user32.lib
includelib c:\masm32\lib\kernel32.lib
;============ data segment =================
_DATA SEGMENT
HANDL DWORD ?
BUFER DB "Hello world\n", 0
NUMB DWORD ?
NUMW DWORD ?
_DATA ENDS
_TEXT SEGMENT
MAIN:
;====== Get the output handle ======
PUSH STD_OUTPUT_HANDLE
CALL [email protected]
MOV HANDL, EAX
; Output the buffer contents to the console
PUSH 0
PUSH OFFSET NUMW
PUSH NUMB
PUSH OFFSET BUFER
PUSH HANDL
CALL [email protected]
;Exit application
PUSH 0
CALL [email protected]
_TEXT ENDS
END
我發現在一些論壇,這是由編碼類型造成的。然而它似乎對我的問題並不重要