1

Now and then I get this compilation error when compiling a c-file in Eclipse.

c:/mingw/bin/../lib/gcc/mingw32/4.7.2/../../../../mingw32/bin/ld.exe: cannot open output file main.exe: Permission denied

It happends when I have made a change in the source-code - but not always.

I know how to solve this* but I would like to know WHY it occurs and how to avoid it?

*In eclipse I go to the debugger and terminate the main thread of the program

ks1322
  • 33,961
  • 14
  • 109
  • 164
Björn Hallström
  • 3,775
  • 9
  • 39
  • 50

1 Answers1

9

You said it yourself, it happens because the program being compiled is still running.

In Windows, you can't make changes to the exe file of a program when it's running.

It's fantastically annoying, and one of those things that (to me) make Windows slightly less comfortable than e.g. Linux for development.

unwind
  • 391,730
  • 64
  • 469
  • 606
  • +1, I wonder how does Linux, does it works with a copy of the binary? – David Ranieri Nov 08 '13 at 10:15
  • Relevant: http://stackoverflow.com/questions/1204078/what-happens-when-you-run-a-program It looks like it just copies the binary into memory – kjh Jul 25 '14 at 18:27