vc中的链接错误++

发布于 2024-12-22 13:52:26 字数 420 浏览 3 评论 0原文

我对 VC++ 很陌生,这是我第一次在 VC++ 上运行程序。 我严格遵循Microsoft Visual C++编程一书中给出的说明,并按照给出的说明创建了一个项目。

关于 ex03a.exe: 我在路径“...\Ex03a\Debug\”中看到,不存在诸如 ex03a.exe 之类的文件。

我通过执行一个简单的“Test.cpp”文件来测试我的 vc++。 我能够运行简单的 C++ 程序并获得输出。并且 Test.exe 位于“\Test\Debug\Test.exe”

我的问题: 我怎样才能摆脱这个错误。 在此处输入图像描述

I am very new to VC++ and I am running the program on VC++ for the first time.
I strictly followed the instructions given in Microsoft Programming Visual C++ book and created one project as instructions given.

About the ex03a.exe:
I saw in the path "...\Ex03a\Debug\" and in that no file exists such as ex03a.exe.

I tested my vc++ by executing a simple 'Test.cpp' file. I was able to run the simple c++ program and I got the output. And Test.exe is there in '\Test\Debug\Test.exe'

My Question:
How could I get rid off the error.
enter image description here

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

↙厌世 2024-12-29 13:52:26

几乎总是当 VS 说它无法打开文件时,它是关于打开它进行写入的。

而且几乎总是这不起作用,因为文件被锁定。

这几乎总是因为该文件是当前正在运行的可执行文件:-)

这是 Windows 的特点 - exe 不是简单地加载,它在所有运行时都被锁定。这可能是因为 exe 文件(实际上称为可移植可执行文件,无论出于何种原因)不仅包含代码,而且通常还包含任意数量的资源(如图像等),并且动态更改文件将使当应用程序尝试在运行时读取这些资源之一时,应用程序会严重崩溃。

因此,我建议寻找一种退出/关闭/终止应用程序的方法,这样它就不再运行,因此文件不再被锁定,因此在这种情况下链接器可以完成其工作。

顺便说一句,从我的角度来看,错误消息并不是那么直观 - 这个问题是如此标准,它至少可以尝试告诉您有关问题的可能来源的任何信息 - 据我所知,这还没有得到改进,直到现在,可能是因为大多数开发人员以前都见过这种情况,找出了它发生的原因,因此不再有任何问题。

Almost always when VS says it isn't able to open a file, it's about opening it for writing.

And almost always this doesn't work because the file is locked.

And almost always this is because the file is an executable that is currently running :-)

This is a specialty of Windows - an exe is not simply loaded, it's locked for all of it's run time. This is probably due to the fact that exe files (actually called portable executables, for whatever reason) contain not only code, but usually also an arbitrary number of resources (like images, etc.), and changing the file on the fly would make the aplication crash hard when it attempts to read one of those resources at run time.

Therefore, I suggest looking for a way to exit / close / terminate the application, so it isn't running any longer, so the file is not locked anymore, so in this case the linker can do its work.

The error message, btw., isn't that intuitive from my point of view - this problem being SO standard, it could at least attempt to tell you anything about this possible source of the problem - afaik, this hasn't been improved until now, probably because most developers have seen this before, found out why it happened, and therefore do not have any more problems with it.

淡墨 2024-12-29 13:52:26

我在该屏幕截图中看到您正在运行多个版本的 VC6。

现在,如果您运行该程序新编译的 exe,而不关闭先前编译的 exe,则会出现该错误。

VC 尝试覆盖当前正在运行的 exe,但遇到了确切的错误。

完成后请务必关闭程序。

I see that in that screenshot, that you are running multiple versions of VC6.

Now You get that error if you run the newly compiled exe of that program without shutting down the previous compiled exe.

VC tries to overrwrite the exe that is currenty running but encounters that exact error.

Always close the program when you are done.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文