我从以下网站下载并提取了 MASM32 + SDK:http: //www.masm32.com/masmdl.htm
然后我使用 ml.exe 和 link.exe 编译并链接了以下程序:
.386
.model flat, stdcall
; Windows libraries
includelib \masm32\lib\kernel32.lib
includelib \masm32\lib\user32.lib
extrn MessageBoxA@16 : PROC
extrn ExitProcess@4 : 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 MessageBoxA@16
call ExitProcess@4
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 _MessageBoxA@16
test.obj : error LNK2001: unresolved external symbol _ExitProcess@4
test.exe : fatal error LNK1120: 2 unresolved externals
尝试在 .obj 文件上运行垃圾箱:
Dump of file test.obj
test.obj : warning LNK4048: Invalid format file; ignored
Summary
我无法使用 MASM32 (ml.exe v. 6.14) 的默认功能和开箱即用的库来链接文件,这对我来说似乎很奇怪。