我下载并提取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