C++ Visual Studio 调试器错误:无法启动程序找不到指定的文件

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/7013309/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-28 16:21:29  来源:igfitidea点击:

Visual Studio debugger error: Unable to start program Specified file cannot be found

c++cvisual-studio-2010debuggingvisual-c++

提问by Makers_F

I have a solution in C:\full path here\VS2010\blender.sln

我在 C:\full path here\VS2010\blender.sln 中有一个解决方案

This solution contains many projects(around 100). When I compile them, they all work fine. I can run them without any problem, and (quite) everything works (there are some bugs). One of the projects is ALL_BUILD, but it gives the same error if I try to debug INSTALL(another project). I'm compiling with RELWithDebInfo as configuration, and if I execute the program manually it works. It is outputted in C:\full path here\VS2010\bin\RelWithDebInfo

该解决方案包含许多项目(大约 100 个)。当我编译它们时,它们都可以正常工作。我可以毫无问题地运行它们,并且(相当)一切正常(有一些错误)。其中一个项目是 ALL_BUILD,但如果我尝试调试 INSTALL(另一个项目),它会给出相同的错误。我正在使用 RELWithDebInfo 作为配置进行编译,如果我手动执行该程序,它就可以工作。输出在C:\full path here\VS2010\bin\RelWithDebInfo

But if I try to run the compiler, it says

但是如果我尝试运行编译器,它会说

"Unable to start program C:\full path here\VS2010\RelWithDebInfo\ALL_BUILD Specified file cannot be found"

“无法启动程序 C:\此处的完整路径\VS2010\RelWithDebInfo\ALL_BUILD 找不到指定的文件”

I tried to copy the compiled program into the path required by VS, but it raised the same error.

我试图将编译后的程序复制到 VS 所需的路径中,但它引发了同样的错误。

What should I do to solve this? Right now I set up cmake to generate also a mingw project and I compile it and debug it with gdb, but this is a really a slow and impractical workflow, and I would like to use the VS debugger.

我该怎么做才能解决这个问题?现在我设置 cmake 来生成一个 mingw 项目,我编译它并用 gdb 调试它,但这确实是一个缓慢且不切实际的工作流程,我想使用 VS 调试器。

I must say that if I compile with Debug as configuration, the program doesn't even start.

我必须说,如果我使用 Debug 作为配置进行编译,程序甚至不会启动。

I'm using VS2010 Express on Win7 64bit

我在 Win7 64 位上使用 VS2010 Express

(This is a big open source program, so I don't know exactly whatever it does)

(这是一个很大的开源程序,所以我不知道它到底做了什么)

回答by Bart

Guessing from the information I have, you're not actually compiling the program, but trying to run it. That is, ALL_BUILD is set as your startup project. (It should be in a bold font, unlike the other projects in your solution) If you then try to run/debug, you will get the error you describe, because there is simply nothing to run.

根据我掌握的信息,您实际上并不是在编译程序,而是在尝试运行它。也就是说,ALL_BUILD 设置为您的启动项目。(它应该是粗体,与您的解决方案中的其他项目不同)如果您然后尝试运行/调试,您将收到您描述的错误,因为根本没有任何东西可以运行。

The project is most likely generated via CMAKE and included in your Visual Studio solution. Set any of the projects that do generate a .exe as the startup project (by right-clicking on the project and selecting "set as startup project") and you will most likely will be able to start those from within Visual Studio.

该项目很可能通过 CMAKE 生成并包含在您的 Visual Studio 解决方案中。将任何生成 .exe 的项目设置为启动项目(通过右键单击该项目并选择“设置为启动项目”),您很可能将能够从 Visual Studio 中启动这些项目。

回答by Taqiyeddine Abderrahim

I had the same problem :) Verify the "Source code" folder on the "Solution Explorer", if it doesn't contain any "source code" file then :

我遇到了同样的问题 :) 验证“解决方案资源管理器”上的“源代码”文件夹,如果它不包含任何“源代码”文件,则:

Right click on "Source code" > Add > Existing Item > Choose the file You want to build and run.

右键单击“源代码”> 添加 > 现有项目 > 选择要构建和运行的文件。

Good luck ;)

祝你好运 ;)

回答by floyd73

I think that what you have to check is:

我认为你必须检查的是:

  1. if the target EXE is correctly configured in the project settings ("command", in the debugging tab). Since all individual projects run when you start debugging it's well possible that only the debugging target for the "ALL" solution is missing, check which project is currently active (you can also select the debugger target by changing the active project).

  2. dependencies (DLLs) are also located at the target debugee directory or can be loaded (you can use the "depends.exe" tool for checking dependencies of an executable or DLL).

  1. 如果在项目设置中正确配置了目标 EXE(“命令”,在调试选项卡中)。由于所有单个项目在您开始调试时都会运行,因此很可能仅缺少“ALL”解决方案的调试目标,请检查当前处于活动状态的项目(您也可以通过更改活动项目来选择调试器目标)。

  2. 依赖项 (DLL) 也位于目标 debugee 目录或可以加载(您可以使用“depends.exe”工具检查可执行文件或 DLL 的依赖项)。