次の Web サイトから 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) の既定の機能と、すぐに使用できるライブラリを使用してファイルをリンクできないのは、私には奇妙に思えます。