...bin\avr-ar: unable to rename 'core.a'; reason: File exists

When trying to upload a sketch to Mega256 got this message.
What does it mean?
this is the full message:
C:\Program Files (x86)\arduino-1.0.3\hardware\tools\avr\bin\avr-ar: unable to rename 'core.a'; reason: File exists
Binary sketch size: 33,654 bytes (of a 258,048 byte maximum)
not enough memory?

You get this from compiling ? or uploading ?

When you ask it to upload, the IDE does a compile first, then an upload.
Or you can ask the IDE to compile, and it just does the compile.

That looks to me like a compiler problem. One possibility, is that a file which the
compiler is trying to delete and replace, has become "read-only", so it cannot be deleted
and replaced. Some kind of PC backup software do stunts like this.

Looks like a memory problem:
I'm trying to use an array.
Reducing the size fixes the problem.

This error has been a pain in the a.. for a long time and it seems nobody can fix it. I get random compile errors with 'core.a' about every four or five compiles. I just hit the upload button again and it usually goes through OK the next time. Sometimes I have to try a few times before it compiles properly. I have 1.0.5 running on XP loading to Unos and Nanos. I have tried just about everything I can think of except buying a new laptop but I haven't found anything that eliminates this PITA Arduino IDE bug.

I also sometimes get double sketches opening at the same time. I have to constantly keep checking how many sketches are open and close any duplicates that open. The Arduino IDE is a bit flakey but its free so I live with it since I have no choice.

That worked for me, I told it to compile again and the second time it came back with no error codes!

Why are you using that ancient version of Arduino? If you're wedded to 1.0.x, use 1.0.6. Otherwise, use a new version.

I'm using the (now) current IDE, 1.8.5, and still get the same symptoms when compiling for the Mega 2560. Like others above, I just compile a second (or third, fourth) time and it works. It's a small nuisance, but it would be nice for it to be fixed.

Having the same problem with any hardware and IDE 1.8.5. Sometimes, rebooting the pc helps.
Didn't have this problem with earlier versions :o

Same problem here. I can't compile anything for my Teensy 3.5. Every time I get this error.
Did anybody manage to figure out a solution?

I should add, I am on Windows 7 (64bit), Arduino 1.8.6

A temp fix which works for me is turning off the McAfee antivirus. Yes, it's very annoying.