程序集masm链接器链接出错:额外操作数'

时间:2013-10-30 09:03:31

标签: assembly linker linker-errors masm32

我为汇编编程安装了masm但是我的代码

下面的链接有问题
.586
.MODEL FLAT
.STACK 4096
INCLUDE io.h

.DATA
prompt      BYTE "shalgham", 0

.CODE
_main       PROC
            output  prompt

            mov     eax, 0
            ret
_main       ENDP
END

当我通过commandLine组装上面的代码时,每件事都没问题 但是当我想链接它时,错误将在commandLine中打印

C:\Users\mahdi\Desktop\New folder>ml /c /coff simple.asm
Microsoft (R) Macro Assembler Version 6.14.8444
Copyright (C) Microsoft Corp 1981-1997.  All rights reserved.

 Assembling: simple.asm

C:\Users\mahdi\Desktop\New folder>link /subsystem:console /entry:main simple.obj
 io.obj Kernel32.Lib
link: extra operand `simple.obj'
Try `link --help' for more information.  

当我使用visual studio 2010时,会打印错误。

1>InitializeBuildStatus:
1>  Touching "Debug\console32.unsuccessfulbuild".
1>_MASM:
1>  Assembling [Inputs]...
1>GenerateTargetFrameworkMonikerAttribute:
1>Skipping target "GenerateTargetFrameworkMonikerAttribute" because all output files are up-to-date with respect to the input files.
1>temp.obj : error LNK2001: unresolved external symbol itoaproc
1>temp.obj : error LNK2001: unresolved external symbol atoiproc
1>temp.obj : error LNK2001: unresolved external symbol dtoaproc
1>temp.obj : error LNK2001: unresolved external symbol atodproc
1>temp.obj : error LNK2001: unresolved external symbol inproc
1>temp.obj : error LNK2019: unresolved external symbol outproc referenced in function _main
1>E:\programming\assembly\VS2010_files\console32\Debug\console32.exe : fatal error LNK1120:     6 unresolved externals
1>
1>Build FAILED.
1>
1>Time Elapsed 00:00:06.14
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

在提出这个问题之前,我搜索它但未找到解决方案

1 个答案:

答案 0 :(得分:2)

虽然@Michael回答了这个问题,但我想说清楚。

我们必须将CYGWIN路径放在MS Visual Studio路径后面。

 Path=....C:\Program Files (x86)\Microsoft Visual Studio\VC98\bin;C:\cygwin\bin

打开Windows命令提示符:

cmd
link --help

确保:

Microsoft (R) Incremental Linker Version 6.00.8168
Copyright (C) Microsoft Corp 1992-1998. All rights reserved.