Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Visual Studio complains that .exe is not found when compiling for debug

I have a very simple C++ application.

#include <stdio.h>
#include <iostream>

int main(int argc, char argv[]) {
  cout << "hi" << endl;
}

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."

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?

Thanks for your help.

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.

like image 291
dangerChihuahua007 Avatar asked Dec 23 '11 21:12

dangerChihuahua007


People also ask

How do I fix the debug executable in Visual Studio?

Just use File/Open Project/Solution, select EXE file and Open it. Then select Debug/Start debugging. The other option is to run the EXE first and then Select Debug/Attach to process.

How do I run an exe in debug mode?

Navigate to the .exe file, select it, and select Open. The file appears as a new project under the current solution. With the new file selected, start debugging the app by selecting an execution command, like Start Debugging, from the Debug menu.

How do I run an EXE file in Visual Studio?

In Visual Studio, select File > Open > Project. In the Open Project dialog box, select All Project Files, if not already selected, in the dropdown next to File name. Navigate to the .exe file, select it, and select Open. The file appears in a new, temporary Visual Studio solution.

How can I see the code of exe in Visual Studio?

In Visual Studio you can open any EXE as a 'project'. Just go to File->Open->Project/Solution and browse to the .exe file.


1 Answers

A couple of problems here:

1) This error is about trying to RUN the program, not compile it:

"Unable to start program ..\Debug\myprogram.exe. The system cannot find the file specified."

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

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 :)

like image 167
paulsm4 Avatar answered Oct 31 '22 14:10

paulsm4