“无法打开 a.exe” C++ 中的错误
我正在尝试编译我的 C++ 程序,但是当我按“构建”按钮时,它显示以下错误消息:
c:/gnat/2010/bin/../libexec/gcc/i686-pc-mingw32/4.3.6/ld.exe: 无法打开输出文件 a.exe:无效 参数collect2:ld返回1退出 状态
这并不是第一次这样做。当我多次编辑同一个项目并经常构建它时,似乎最常这样做,几乎就像有些东西被淹没、超载或其他什么一样。
我相信,我之前已经通过重新启动我的电脑来解决这个问题,但我不能每次发生这种情况时都重新启动我的电脑。
我认为这只是一次性问题,但它一直在发生,所以我想我应该在这方面寻求更多帮助。
我发现了另一个SO
还有其他人遇到过这个问题吗?或者有人知道如何解决这个问题(除了每次重新启动计算机之外)?
我也在 jGrasp 中开发,如果这有帮助的话。
编辑:我只是想补充一点,我认为可能是我以前的可执行文件仍在后台运行,但即使我关闭 IDE,它仍然不会让我删除可执行文件,因为它说仍在运行。
我检查了进程资源管理器以查看 a.exe 是否仍在运行,但我的进程中绝对没有任何与 jGrasp 或 a.exe 有关的内容
I'm trying to compile my C++ program, but when I press the "Build" button, it displays the following error message:
c:/gnat/2010/bin/../libexec/gcc/i686-pc-mingw32/4.3.6/ld.exe:
cannot open output file a.exe: Invalid
argument collect2: ld returned 1 exit
status
This is not the first time it has done this. It seems to do this most when I have been editing the same project a lot and building it often, almost as if something has been flooded, or overloaded, or something.
I had fixed it before, I believe, by restarting my PC, but I can't afford to keep restarting my PC every time this occurs.
I thought this was just a one-time problem, but it has continued to happen and so I thought I'd look for more help on this.
I found another SO question that I thought had the same error message/problem as I had. However, when I tried the solutions listed on afore-linked question, nothing helped.
Has anyone else had this issue? Or does anyone know how I can fix this issue (besides restarting my computer every time)?
I am developing in jGrasp also, if that helps any.
EDIT: I just wanted to add that I thought it might be that my previous executable was still running in the background, but even if I close my IDE, it still won't let me delete the executable, because it says it is still running.
I checked my process explorer to see if the a.exe was still running, but there's absolutely nothing in my processes that has to do with jGrasp or a.exe
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
我猜你的可执行文件仍在运行。这是我考虑的唯一原因......我想最好是检查你的任务管理器(进程资源管理器是你的朋友;))。
I guess your executable is still running. It's the only reason I think about... I guess the best is to check on your task manager (process Explorer is your friend ;)).
在 Visual Studio Code 中,转到“设置”->“在搜索栏中搜索“清除先前的输出”,然后选中名为“清除先前的输出”的框。 :)
发生这种情况是因为您之前的输出已经在后台运行。 VS Code 提供了在每次运行时关闭该功能的功能。
In Visual Studio Code, go to Settings -> Search for "clear previous" in the search bar and check on the box named "clear previous output". :)
It is happening because your previous output is already running in the background. And VS Code offers a feature to close that on every run.
编辑:这与collect2.exe无关。
您是否收到任何其他错误文本,例如“权限被拒绝错误”等。
http:// /max.berger.name/howto/cdt/ar01s05.jsp
EDIT: it's nothing to do with collect2.exe.
Do you get any other error text, like for example 'permission denied errors' etc.
http://max.berger.name/howto/cdt/ar01s05.jsp
这是因为 .exe 仍在运行。如果您使用的是 Windows,请使用命令行 del -f a.exe;如果您使用的是 Linux,请使用 rm -rf ./a.out
It is beacause the .exe is still running. If you're on Windows use the command line del -f a.exe and if you're on linux use rm -rf ./a.out
我也有同样的问题,担心了几个小时。我禁用了 avg 防病毒软件,它起作用了。
I have the same problem, was worried for hours. I disabled my avg antivirus and it worked.