简体   繁体   English

vc ++中的链接错误

[英]Linking error in vc++

I am very new to VC++ and I am running the program on VC++ for the first time. 我对VC ++非常陌生,并且是第一次在VC ++上运行该程序。 I strictly followed the instructions given in Microsoft Programming Visual C++ book and created one project as instructions given. 我严格按照Microsoft编程Visual C ++手册中给出的说明进行操作,并按照给出的说明创建了一个项目。

About the ex03a.exe: I saw in the path "...\\Ex03a\\Debug\\" and in that no file exists such as ex03a.exe. 关于ex03a.exe:我在路径“ ... \\ Ex03a \\ Debug \\”中看到,并且不存在诸如ex03a.exe之类的文件。

I tested my vc++ by executing a simple 'Test.cpp' file. 我通过执行一个简单的“ Test.cpp”文件来测试我的vc ++。 I was able to run the simple c++ program and I got the output. 我能够运行简单的c ++程序,并且得到了输出。 And Test.exe is there in '\\Test\\Debug\\Test.exe' Test.exe在“ \\ Test \\ Debug \\ Test.exe”中

My Question: How could I get rid off the error. 我的问题:如何摆脱错误。 在此处输入图片说明

Almost always when VS says it isn't able to open a file, it's about opening it for writing. 几乎总是在VS表示无法打开文件时,它是关于将其打开以进行写入。

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. 这是Windows的特长-并非简单地加载exe,它在所有运行时都被锁定。 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. 这可能是由于exe文件(无论出于何种原因实际上称为可移植可执行文件)不仅包含代码,而且通常还包含任意数量的资源(例如图像等),并且动态更改文件会导致以下事实:当它试图在运行时读取那些资源之一时,应用程序将崩溃。

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. 错误消息,顺便说一句,从我的角度来看不是那么直观-这个问题是SO标准的,它至少可以尝试告诉您有关此问题的可能根源-afaik,直到得到改善现在,可能是因为大多数开发人员以前都已经看过这种情况,所以才知道发生这种情况的原因,因此不再有其他问题。

I see that in that screenshot, that you are running multiple versions of VC6. 我在该屏幕截图中看到,您正在运行多个版本的VC6。

Now You get that error if you run the newly compiled exe of that program without shutting down the previous compiled exe. 现在,如果运行该程序的新编译的exe而不关闭以前的编译的exe,则会收到该错误。

VC tries to overrwrite the exe that is currenty running but encounters that exact error. VC试图覆盖当前正在运行的exe,但遇到该确切错误。

Always close the program when you are done. 完成后,请务必关闭程序。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM