Visual Studio汇编开发遇LNK2019未解析外部符号错误求助
_exitprocess@4错误 我正在大学的汇编语言课程学习,半个学期以来一直在尝试让Visual Studio成功编译汇编程序,但近期遇到了网上未找到相关解决方案的错误。
我的操作步骤如下:
- 创建新的C++项目
- 在解决方案资源管理器中右键项目名称,将构建依赖项设置为MASM (.targets, .props)
- 右键项目名称,选择“添加”->“新建项”
- 添加空白C++文件,将扩展名改为
.asm而非.cpp - 确保以x86模式运行代码
- 编写汇编代码
- 构建项目,但持续报错
我尝试运行的代码功能是将5移入EAX寄存器,再加上6,代码如下:
.386 .model flat, stdcall .stack 4096 exitprocess proto, dwexitcode: Dword .data .code main proc mov eax, 5 add eax, 6 invoke exitprocess, 0 main endp end main
构建项目时返回如下错误:
Build started...
1>------ Build started: Project: Project7, Configuration: Debug Win32 ------
1>Assembling SumAndPrintArray.asm...
1>SumAndPrintArray.obj : error LNK2019: unresolved external symbol _exitprocess@4 referenced in function _main@0
1>C:\Users\richm\source\repos\Project7\Debug\Project7.exe : fatal error LNK1120: 1 unresolved externals
1>Done building project "Project7.vcxproj" -- FAILED.
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
========== Build started at 10:39 PM and took 00.746 seconds ==========
无论创建哪个项目,都会返回LNK2019错误,甚至在另一台电脑上创建新项目也出现同样问题,请问这是怎么回事?
内容的提问来源于stack exchange,提问作者TheRichinator

