我想創建一個只使用masm而不是masm32庫的helloworld程序。以下是代碼片段:錯誤LNK2001:無法解析的外部符號_MessageBox
.386
.model flat, stdcall
option casemap :none
extrn MessageBox : PROC
extrn ExitProcess : PROC
.data
HelloWorld db "Hello There!", 0
.code
start:
lea eax, HelloWorld
mov ebx, 0
push ebx
push eax
push eax
push ebx
call MessageBox
push ebx
call ExitProcess
end start
我能夠組裝本使用MASM:
c:\masm32\code>ml /c /coff demo.asm
Microsoft (R) Macro Assembler Version 9.00.21022.08
Copyright (C) Microsoft Corporation. All rights reserved.
Assembling: demo.asm
但是,我無法將其鏈接:
c:\masm32\code>link /subsystem:windows /defaultlib:kernel32.lib /defaultlib:user
32.lib demo.obj
Microsoft (R) Incremental Linker Version 9.00.21022.08
Copyright (C) Microsoft Corporation. All rights reserved.
demo.obj : error LNK2001: unresolved external symbol _MessageBox
demo.obj : error LNK2001: unresolved external symbol _ExitProcess
demo.exe : fatal error LNK1120: 2 unresolved externals
我包括在庫在鏈接期間,所以不知道爲什麼它仍然說未解決的符號?
UPDATE:
c:\masm32\code>link /subsystem:windows /defaultlib:kernel32.lib /defaultlib:user
32.lib demo.obj
Microsoft (R) Incremental Linker Version 9.00.21022.08
Copyright (C) Microsoft Corporation. All rights reserved.
demo.obj : error LNK2001: unresolved external symbol [email protected]
demo.exe : fatal error LNK1120: 1 unresolved externals
更新2:最後的工作代碼!
.386
.model flat, stdcall
option casemap :none
extrn [email protected] : PROC
extrn [email protected] : PROC
.data
HelloWorld db "Hello There!", 0
.code
start:
lea eax, HelloWorld
mov ebx, 0
push ebx
push eax
push eax
push ebx
call [email protected]
push ebx
call [email protected]
end start
謝謝!這解決了其中一個鏈接錯誤,但不是其他..請參閱更新 – Jumbo 2010-11-08 10:38:51
好點,請參閱我的編輯。 – 2010-11-08 10:42:53
太棒了!現在完美工作。我覺得這樣一個n00b - 你能建議任何文檔/書籍,我可以從中挑選所有這些東西嗎?當你是一個新手時,MSDN太過艱鉅。 – Jumbo 2010-11-08 10:48:26