我下載並提取MASM32 +從以下網站的SDK:使用ML.EXE和LINK.EXE http://www.masm32.com/masmdl.htmMASM32 - 「未解決的外部符號」用下劃線,而鏈接
我然後編譯和鏈接下面的程序:
.386
.model flat, stdcall
; Windows libraries
includelib \masm32\lib\kernel32.lib
includelib \masm32\lib\user32.lib
extrn [email protected] : PROC
extrn [email protected] : PROC
option casemap:none ; Treat labels as case-sensitive
.DATA ; Begin initialized data segment
ProgramTitle db "Hello, puny humans!", 0 ; define byte
DisplayText db "Wahahaha", 0
.CODE ; Begin code segment
_main PROC
push 0
mov eax, offset ProgramTitle
push eax
push offset DisplayText
push 0
call [email protected]
call [email protected]
ret
_main ENDP
END
命令行:
ml /c test.asm
link /entry:_main /subsystem:windows test.obj
輸出:
ml /c test.asm
Assembling: test.asm
link /entry:_main /subsystem:windows test.obj
test.obj : warning LNK4033: converting object format from OMF to COFF
test.obj : error LNK2001: unresolved external symbol [email protected]
test.obj : error LNK2001: unresolved external symbol [email protected]
test.exe : fatal error LNK1120: 2 unresolved externals
嘗試運行在obj文件一個DUMPBIN:(ML.EXE v 6.14)
Dump of file test.obj
test.obj : warning LNK4048: Invalid format file; ignored
Summary
我覺得奇怪,我說,我無法利用鏈接MASM32的默認功能和文件即裝即用的庫。
如果您使用MASM32,則不需要使用像'extrn MessageBoxA @ 16:PROC' /'call MessageBoxA @ 16'這樣的笨拙語法。你可能已經包含了user32.inc並且完成了調用MessageBoxA NULL,ADDR DisplayText,ADDR ProgramTitle,NULL' – Michael 2013-03-26 06:24:33