windows Visual Studio 编译但 exe 不存在
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/3231463/
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
Visual Studio compiles but the exe isn't there
提问by crv
Source code that compiles fine on other peoples environments won't correctly work in my environment. When I do a rebuild the compile occurs but when visual studio goes to move the exe from /obj/debug/{solution} to /debug/{solution} it cannot find the exe in the /obj/debug/{solution}. To make this even more crazy even after I reinstall visual studio it doesn't work. On other people environments it works find. Please note that this is a windows mobile 6, compact framework 3.5 project, Visual C++ project.
在其他人的环境中编译良好的源代码在我的环境中无法正常工作。当我进行重建时,会发生编译,但是当 Visual Studio 将 exe 从 /obj/debug/{solution} 移动到 /debug/{solution} 时,它在 /obj/debug/{solution} 中找不到该 exe。为了使这更加疯狂,即使在我重新安装 Visual Studio 之后它也不起作用。在其他人的环境中它可以找到。请注意,这是一个 windows mobile 6、compact framework 3.5 项目、Visual C++ 项目。
EDIT: Visual Studio 2008 is being used.
编辑:正在使用 Visual Studio 2008。
EDIT2: After looking at the logs again come to find out it says it is compiling but it isn't really compiling. Interesting enough it doesn't throw any errors until it tries to link the code. When it goes to link the object files, they aren't there and it fails.
EDIT2:再次查看日志后,发现它说正在编译,但实际上并没有编译。有趣的是,它在尝试链接代码之前不会抛出任何错误。当它链接目标文件时,它们不存在并且失败。
回答by Marc Schluper
I got TWO Release folders: one in the solution folder and one in the project folder. The former contains the .exe file, the latter does not.
我有两个发布文件夹:一个在解决方案文件夹中,一个在项目文件夹中。前者包含 .exe 文件,后者不包含。
回答by yasouser
In the solution properties page, check whether the path you are expecting the exe to be is same as the one specified in Linker -> Output file.
在解决方案属性页面中,检查您期望 exe 的路径是否与链接器 -> 输出文件中指定的路径相同。
Another obvious mistake could be, check what build configuration you are building. You might be doing a release build and expecting a debug executable file :) I have done this a few times.
另一个明显的错误可能是,检查您正在构建的构建配置。你可能正在做一个发布版本并期待一个调试可执行文件:) 我已经做过几次了。
回答by user3612650
I just wanted to chime in and ask: have you looked for the *.exe file name from the directories above? What I found in my case was it was writing to the directory right above the /release subdirectory. Not sure how I missed that detail, but I did! I suppose it never occurred to me earlier because I saw the buildlog.htm being written to the /release subdirectory, and the very existence of the directory itself. In my case it was compiling, linking, etc. I just wasn't able to see the *.exe in that /release subdirectory.
我只是想插话问:你有没有从上面的目录中寻找 *.exe 文件名?我在我的案例中发现它正在写入 /release 子目录正上方的目录。不知道我是如何错过那个细节的,但我做到了!我想我之前从未想过,因为我看到 buildlog.htm 被写入 /release 子目录,以及目录本身的存在。就我而言,它正在编译、链接等。我只是无法在 /release 子目录中看到 *.exe。
回答by Stefan
Maybe VS creates the exe, and before it tries to move it to the final destination your virus scanner grabs it and removes it, or moves it to a save location.
也许 VS 创建了 exe,在它尝试将其移动到最终目的地之前,您的病毒扫描程序会抓取并删除它,或者将其移动到保存位置。
回答by jameshfisher
There are two subtly different paths. I was looking here, which doesn't exist:
有两条微妙不同的路径。我在看这里,它不存在:
C:\Users\james\source\repos\CppHelloWorld\Release\CppHelloWorld.exe
The actual exe is here - note the path contains the x64
platform that it was built for:
实际的 exe 在这里 - 请注意路径包含x64
它构建的平台:
C:\Users\james\source\repos\CppHelloWorld\x64\Release\CppHelloWorld.exe
In general, the path seems to be:
一般来说,路径似乎是:
$PROJECT_PATH$PROJECT_NAME$PLATFORM$CONFIGURATION$PROJECT_NAME.exe
回答by ctacke
If the exact same solution works on other machines, then it's an environment problem and no amount of looking at the project, linker, etc is going to resolve this. What is different about the environments? Are the same service packs and QFE's applied for not just Studio, but also the OS? Is there a difference in processors (64/32-bit)? Are your permissions the same? Do you have the same SDKs installed?
如果完全相同的解决方案适用于其他机器,那么这是一个环境问题,并且看项目、链接器等都无法解决这个问题。环境有什么不同?相同的服务包和 QFE 是否不仅适用于 Studio,还适用于操作系统?处理器(64/32 位)有区别吗?你的权限一样吗?您是否安装了相同的 SDK?
I'd agree with Shahi that just trying to build a "hello world" app against the same SDK and see if it will compile is valuable info.
我同意 Shahi 的观点,即尝试针对同一个 SDK 构建一个“hello world”应用程序并查看它是否会编译是有价值的信息。
回答by Daniel Rose
Perhaps you do not have write permission to the output folder? If you are running on Vista/7, is your Visual Studio running as elevated?
也许您没有输出文件夹的写权限?如果您在 Vista/7 上运行,您的 Visual Studio 是否以提升的方式运行?
回答by Simon
I had exactly the same problem. Just close Visual Studio and reopen it again (basically restart it) and it should work.
我遇到了完全相同的问题。只需关闭 Visual Studio 并再次重新打开它(基本上重新启动它),它应该可以工作。
回答by Riley
I've found this to be random for myself in now VS2016. My work around has been to just create another project and copy the contents from the one with out the .exe to the new one. For some reason the new one normally will have the proper .exe and location needed. While this isn't a complete solution at least it's been working for me for the time being.
我发现这在现在的 VS2016 中对我自己来说是随机的。我的工作是创建另一个项目并将内容从没有 .exe 的项目复制到新项目。出于某种原因,新的通常会有正确的 .exe 和所需的位置。虽然这不是一个完整的解决方案,但至少它暂时对我有用。
回答by RBT
It happened with me today:
今天发生在我身上:
TL;DR;You might be using some C# code in your project who belong to a language version which is not supported by the .NET Framework version targeted by your project
TL; 博士; 您可能在您的项目中使用了一些 C# 代码,这些代码属于您的项目所针对的 .NET Framework 版本不支持的语言版本
Details:
详情:
I had two projects in my solution. One project was already existing. I added a new project targeting most recent .NET Framework v4.6.1 supported by Visual Studio(VS) 2017 class library project template. I used some C# language features which is present in C# v7.0. In such a case, VS can compile the project but can't create the output in bin
directory.
我的解决方案中有两个项目。一个项目已经存在。我添加了一个新项目,目标是 Visual Studio(VS) 2017 类库项目模板支持的最新 .NET Framework v4.6.1。我使用了 C# v7.0 中存在的一些 C# 语言功能。在这种情况下,VS 可以编译项目但不能在bin
目录中创建输出。
Eventually I had to merge the new project code files into the existing old project which was targeting .NET Framework v4.5.1.
最终,我不得不将新项目代码文件合并到针对 .NET Framework v4.5.1 的现有旧项目中。
So I changed the target Framework version to the latest .NET Framework v4.6.1 for the existing projects also. Then the old project also started supporting my newly pasted C# language features.
因此,我也将现有项目的目标框架版本更改为最新的 .NET Framework v4.6.1。然后旧项目也开始支持我新粘贴的 C# 语言功能。