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

后端 未结 12 1605
庸人自扰
庸人自扰 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 08:54

    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!

    0 讨论(0)
  • 2020-11-29 08:55

    I have recently not used VS 2010.

    Does your application really build correctly? To get more control in VS 2010 C++ Express, you can check menu item "Expert Settings" under Tools>Settings to get a Build' menu.
    After clicking Build->Build Solution (or Rebuild), you may verify in Output window (View->Outout), if your application is compiling and linking correctly.

    Sources :

    • http://social.msdn.microsoft.com/Forums/en-US/vsdebug/thread/e60f9f37-69ad-47f3-b1d3-132aabe68f86
    • http://cboard.cprogramming.com/cplusplus-programming/135322-error-system-cannot-find-file-specified.html

    Hope it helps.

    0 讨论(0)
  • 2020-11-29 08:55

    I got this problem during debug mode and the missing file was from a static library I was using. The problem was solved by using step over instead of step into during debugging

    0 讨论(0)
  • 2020-11-29 08:57

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

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

    I know this is an old thread, but for any future visitors, the cause of this error is most likely because you haven't built your project from Build > Build Solution. The reason you're getting this error when you try to run your project is because Visual Studio can't find the executable file that should be produced when you build your project.

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

    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:

    Right Click Project Name > Properties
    Linker > General 
    Output File > $(OutDir)$(TargetName)$(TargetExt) as indicated by @ReturnVoid
    Click Apply
    

    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:

    Back in Project > Properties > Linker > General > Output File > 
    

    You'll see the previously entered text in bold

    Select Drop Down > Select "inherit from parent or project defaults"
    Select Apply
    

    Previously bold font is no longer bold

    Build > Rebuild > Debug
    

    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

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