问题描述
我有一个非常简单的 C++ 应用程序.
I have a very simple C++ application.
#include <stdio.h>
#include <iostream>
int main(int argc, char argv[]) {
cout << "hi" << endl;
}
当我在调试模式下第一次编译时,Visual Studio 抱怨无法启动程序 ..\Debug\myprogram.exe.系统找不到指定的文件."
When I compile for the first time in debug mode, Visual Studio complains "Unable to start program ..\Debug\myprogram.exe. The system cannot find the file specified."
但是,我认为这是显而易见的,因为我是第一次编译,对吗?这个可执行文件不应该存在,那么为什么 Visual Studio 会犹豫不决呢?
However, I think that this is obvious because I am compiling for the first time, right? This executable should not exist yet, so why is Visual Studio balking at compiling?
感谢您的帮助.
此外,当我构建时,会出现以下日志:
Also, when I build, the following log appears:
当我构建(构建->构建解决方案.)时,出现此日志:
When I build (Build->Build solution.), this log appears:
1>------ Build started: Project: print_digits, Configuration: Debug Win32 ------
1>Build started 12/23/2011 4:32:17 PM.
1>InitializeBuildStatus:
1> Creating "Debug\print_digits.unsuccessfulbuild" because "AlwaysCreate" was specified.
1>FinalizeBuildStatus:
1> Deleting file "Debug\print_digits.unsuccessfulbuild".
1> Touching "Debug\print_digits.lastbuildstate".
1>
1>Build succeeded.
1>
1>Time Elapsed 00:00:00.08
它说构建成功,但由于某种原因没有构建可执行文件.
It says build succeeded, but no executable is being built for some reason.
推荐答案
这里有几个问题:
1) 这个错误是关于试图运行程序,而不是编译它:
1) This error is about trying to RUN the program, not compile it:
无法启动程序..\Debug\myprogram.exe.系统无法启动找到指定的文件."
2) 可能找不到程序的原因是它编译失败.
2) Probably the reason it can't find the program is because it FAILED to COMPILE.
以下是我从你的来源得到的错误:
Here are the errors I got from your source:
tmp.cpp(5) : error C2065: 'cout' : undeclared identifier
tmp.cpp(5) : error C2297: '<<' : illegal, right operand has type 'char [3]'
tmp.cpp(5) : error C2065: 'endl' : undeclared identifier
tmp.cpp(6) : warning C4508: 'main' : function should return a value; 'void' return type assumed
如果您添加using namespace std;",您应该能够修复这些特定错误
You should be able to fix these particular errors if you add "using namespace std;"
获得干净的编译,您应该能够运行调试器:)
Get a clean compile, and you should be able to run the debugger :)
这篇关于Visual Studio 抱怨编译调试时找不到 .exe的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!