I installed Visual Studio 2010. I wrote a simple code which I'm sure is correct but unfortunately, when I run the code, I get the error below.
Here is my code:
#include<iostream>
using namespace std;
int main (){
cout <<"Hello StackOverFlow ;)";
return 0;
}
And here is the error:
Unable to start program 'C:\Users\Soheil\Desktop\New folder\sam\Debug\sam.exe The system cannot find the file specified
Would you help me solve the issue? Should I define the project in a specific directory? I've spent a ton of hours to solve this issue and have not had any success yet.
For me, I didn't have my startup project set in Solution Explorer.
Go to Solution Explorer on the left of VS, right click your unit test project, and choose "set as startup project".
I had just ported my code to a new workspace, and forgot that when I opened the project in VS in the solution there, that I needed to re-set my startup project.
I had a same problem and i could fixed it! you should add C:\Program Files (x86)\Microsoft SDKs\Windows\v7.1A\Lib\x64 for 64 bit system / C:\Program Files (x86)\Microsoft SDKs\Windows\v7.1A\Lib for 32 bit system in property manager-> Linker-> General->Additional library Directories
maybe it can solve the problem of somebody in the future!
This is a first step for somebody that is a beginner. Same thing happened to me:
Look in the Solution Explorer box to the left. Make sure that there is actually a
.cpp
file there. You can do the same by looking the.cpp
file where the.sln
file for the project is stored. If there is not one, then you will get that error.When adding a cpp file you want to use the Add new item icon. (top left with a gold star on it, hover over it to see the name) For some reason Ctrl+N does not actually add a
.cpp
file to the project.Since this thread is one of the top results for that error and has no fix yet, I'll post what I found to fix it, originally found in this thread: Build Failure? "Unable to start program... The system cannot find the file specificed" which lead me to this thread: Error 'LINK : fatal error LNK1123: failure during conversion to COFF: file invalid or corrupt' after installing Visual Studio 2012 Release Preview
Basically all I did is this:
Project Properties -> Configuration Properties -> Linker (General) -> Enable Incremental Linking -> "No (/INCREMENTAL:NO)"
As others have mentioned, this is an old thread and even with this thread there tends to be different solutions that worked for different people. The solution that worked for is as follows:
For whatever reason this initial correction didn't fix my problem (I'm using VS2015 Community to build c++ program). If you still get the error message try the following additional steps:
You'll see the previously entered text in bold
Previously bold font is no longer bold
It doesn't make since to me to require these additional steps in addition to what @ReturnVoid posted but...what works is what works...hope it helps someone else out too. Thanks @ReturnVoid
I came across this problem and none of these solution worked 100%
In addition to ReturnVoid's answer which suggested the change
I needed to changed
This field was blank for me, changing the contents to
/Zi
(or/Z7
or/ZI
if those are the formats you want to use) allowed me to debug