“Cannot Open a.exe” Error in C++

守給你的承諾、 提交于 2019-12-20 03:19:17

问题


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


回答1:


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 ;)).




回答2:


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




回答3:


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



来源:https://stackoverflow.com/questions/4648808/cannot-open-a-exe-error-in-c

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!