“The system cannot find the file specified” when running C++ program

后端 未结 12 1606
庸人自扰
庸人自扰 2020-11-29 08:30

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:

相关标签:
12条回答
  • 2020-11-29 09:09

    I know this thread is 1 year old but I hope this helps someone, my problem was that I needed to add:

        #include "stdafx.h"
    

    to my project (on the first line), this seems to be the case most of the time!

    0 讨论(0)
  • 2020-11-29 09:11

    I came across this problem and none of these solution worked 100%

    In addition to ReturnVoid's answer which suggested the change

    Project Properties -> Linker -> Output file -> $(OutDir)$(TargetName)$(TargetExt)

    I needed to changed

    Project Properties -> C/C++ -> Debug Information Format -> /Zi

    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

    0 讨论(0)
  • 2020-11-29 09:14

    Encountered the same issue, after downloading a project, in debug mode. Searched for hours without any luck. Following resolved my problem;

    Project Properties -> Linker -> Output file -> $(OutDir)$(TargetName)$(TargetExt)

    It was previously pointing to a folder that MSVS wasn't running from whilst debugging mode.

    EDIT: soon as I posted this I came across: unable to start "program.exe" the system cannot find the file specified vs2008 which explains the same thing.

    0 讨论(0)
  • 2020-11-29 09:16

    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.

    0 讨论(0)
  • 2020-11-29 09:18

    if vs2010 installed correctly

    check file type (.cpp)

    just build it again It will automatically fix,, ( if you are using VS 2010 )

    0 讨论(0)
  • 2020-11-29 09:19

    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.

    0 讨论(0)
提交回复
热议问题