MASM32 - “未解决的外部符号”用下划线,而链接
我下载并提取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的默认功能和文件即装即用的库。
程序必须使用/ coff选项进行编译。 ml 6.14默认为OMF。这是两者的DUMPBIN拒绝该文件(它只接受COFF)的原因和接头警告“对象格式转换从OMF到COFF”:
ml /c /coff test.asm
的DUMPBIN输出反映了这一:
File Type: COFF OBJECT
Summary
1D .data
48 .drectve
1A .text
除了test.exe和微软版权声明之外,链接器不提供任何输出。
注:
ML.EXE 6.14大约是20岁。 (Wikipedia)
版本7.0+与Visual C++开发环境捆绑在一起。版本8.0或更高版本是有一定的限制:(masm32.com)
“版本7.0及以上的都是微软的Visual C++ 开发环境的组成部分,并也取得了提供的设备开发工具包的一些 的后续版本Microsoft Windows。版本8.0和更高版本已作为免费下载从Microsoft提供 根据EULA限制使用免费版本 来开发Microsoft操作系统的代码。
MASM 8.0可以在这里找到: http://www.microsoft.com/en-us/download/details.aspx?id=12654
EXTRA注意与6.14,
ML.EXE会忽略在这种情况下,/ COFF选项
ml test.asm /c /coff
(奇怪的问题。)
ml.exe将考虑到/ coff选项。
ml /c /coff test.asm
也许这是因为这是语法:'ML [/ options] filelist [/ link linkoptions]' – Daan 2015-09-11 20:58:17
如果您使用MASM32,则不需要使用像'extrn MessageBoxA @ 16:PROC' /'call MessageBoxA @ 16'这样的笨拙语法。你可能已经包含了user32.inc并且完成了调用MessageBoxA NULL,ADDR DisplayText,ADDR ProgramTitle,NULL' – Michael 2013-03-26 06:24:33