2

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

Community
  • 1
  • 1
AmbiguousX
  • 1,704
  • 4
  • 24
  • 39
  • I've been having similar things *constantly* since using Windows 7, searched a lot, never found a final solution. The only thing that helps is waiting a couple of minutes, then the file can be deleted/overwritten/... Weird thing is, even using handle.exe and the likes, the file is not listed. – stijn Jan 10 '11 at 16:42
  • @stijn, Yea, it's really frustrating. Although I've been waiting for over an hour now and it still isn't allowing me to delete the a.exe or overwrite it. Really aggravating. I wonder if it has something to do with Windows 7... – AmbiguousX Jan 10 '11 at 16:44
  • hmm maybe it's a different problem than mine then: I neer have to wait an hour. What I observed is usually after simply selecting an executable in explorer, or running it, something kicks in that makes the file readonly. Eg I also have it for batch files: sometimes after running a batch file, I cannot edit and save it for a couple of minutes. Never happens for non-executables though. – stijn Jan 10 '11 at 17:05
  • @stijn: since it's only executables, could it be an anti-virus problem? – Emilio Silva Jan 14 '11 at 23:06
  • no don't run anti-virus. It also occurs on all my developments machines btw. – stijn Jan 15 '11 at 08:51
  • The problem is with jgrasp and you should report a bug to them. Meanwhile you should find a way to produce **full build logs**. There is absolutely no way to help you without them. – n. m. could be an AI Jul 03 '17 at 09:24

5 Answers5

2

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

Grokwik
  • 511
  • 4
  • 6
  • I edited the question to include this info, but I tried looking at the processes explorer as well and it's not in there – AmbiguousX Jan 10 '11 at 16:35
1

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.

Aman
  • 167
  • 2
  • 9
0

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

lvndry
  • 421
  • 6
  • 13
0

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

trojanfoe
  • 120,358
  • 21
  • 212
  • 242
  • no I don't get any other errors at all except the one mentioned above and the error Windows gives me if I try to delete the a.exe from windows explorer – AmbiguousX Jan 10 '11 at 16:34
0

I have the same problem, was worried for hours. I disabled my avg antivirus and it worked.

Steve
  • 1