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

2020-04-12 09:00发布

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

3条回答
SAY GOODBYE
2楼-- · 2020-04-12 09:41

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

查看更多
We Are One
3楼-- · 2020-04-12 09:46

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

查看更多
时光不老,我们不散
4楼-- · 2020-04-12 09:50

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

查看更多
登录 后发表回答