First off - I'm new to Arduino and this forum so apologies if I make any rookie errors. I've looked on Google, the forum and the Troubleshooting Guide and read the forum posting guidance.
I've got a MEGA 2560 and I'm running version 1.8.13 of the IDE. I'm trying things out using the Blink example program.
The problem I'm seeing is that the first time I compile my program, it's fine but the second time, I see "Error Compiling for board Arduino Mega or Mega 2560". (more details below).
If the first compile is part of an upload (so an implicit compile), the Arduino is updated with my program. I've made sure of that by altering the blink speed. There is no doubt that the modified code ends up on the processor - I see the blink rate change.
The second time I try to upload, I hit the error mentioned below. Even if I just compile the first time and don't upload, the second compile will fail, so I think it's a problem with what the IDE is doing rather than anything associated with the board.
The error message I get is:
Arduino: 1.8.13 (Windows Store 1.8.39.0) (Windows 10), Board: "Arduino Mega or Mega 2560, ATmega2560 (Mega 2560)"
C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.39.0_x86__mdqgnx93n4wtt\arduino-builder -dump-prefs -logger=machine -hardware C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.39.0_x86__mdqgnx93n4wtt\hardware -tools C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.39.0_x86__mdqgnx93n4wtt\tools-builder -tools C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.39.0_x86__mdqgnx93n4wtt\hardware\tools\avr -built-in-libraries C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.39.0_x86__mdqgnx93n4wtt\libraries -libraries C:\Users\kaf\Documents\Arduino\libraries -fqbn=arduino:avr:mega:cpu=atmega2560 -vid-pid=2341_0042 -ide-version=10813 -build-path C:\Users\kaf\AppData\Local\Temp\arduino_build_516505 -warnings=all -prefs=build.warn_data_percentage=75 -prefs=runtime.tools.arduinoOTA.path=C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.39.0_x86__mdqgnx93n4wtt\hardware\tools\avr -prefs=runtime.tools.arduinoOTA-1.3.0.path=C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.39.0_x86__mdqgnx93n4wtt\hardware\tools\avr -prefs=runtime.tools.avr-gcc.path=C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.39.0_x86__mdqgnx93n4wtt\hardware\tools\avr -prefs=runtime.tools.avr-gcc-7.3.0-atmel3.6.1-arduino7.path=C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.39.0_x86__mdqgnx93n4wtt\hardware\tools\avr -prefs=runtime.tools.avrdude.path=C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.39.0_x86__mdqgnx93n4wtt\hardware\tools\avr -prefs=runtime.tools.avrdude-6.3.0-arduino17.path=C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.39.0_x86__mdqgnx93n4wtt\hardware\tools\avr -verbose C:\code\arduino\myblink\myblink.ino
C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.39.0_x86__mdqgnx93n4wtt\arduino-builder -compile -logger=machine -hardware C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.39.0_x86__mdqgnx93n4wtt\hardware -tools C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.39.0_x86__mdqgnx93n4wtt\tools-builder -tools C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.39.0_x86__mdqgnx93n4wtt\hardware\tools\avr -built-in-libraries C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.39.0_x86__mdqgnx93n4wtt\libraries -libraries C:\Users\kaf\Documents\Arduino\libraries -fqbn=arduino:avr:mega:cpu=atmega2560 -vid-pid=2341_0042 -ide-version=10813 -build-path C:\Users\kaf\AppData\Local\Temp\arduino_build_516505 -warnings=all -prefs=build.warn_data_percentage=75 -prefs=runtime.tools.arduinoOTA.path=C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.39.0_x86__mdqgnx93n4wtt\hardware\tools\avr -prefs=runtime.tools.arduinoOTA-1.3.0.path=C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.39.0_x86__mdqgnx93n4wtt\hardware\tools\avr -prefs=runtime.tools.avr-gcc.path=C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.39.0_x86__mdqgnx93n4wtt\hardware\tools\avr -prefs=runtime.tools.avr-gcc-7.3.0-atmel3.6.1-arduino7.path=C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.39.0_x86__mdqgnx93n4wtt\hardware\tools\avr -prefs=runtime.tools.avrdude.path=C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.39.0_x86__mdqgnx93n4wtt\hardware\tools\avr -prefs=runtime.tools.avrdude-6.3.0-arduino17.path=C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.39.0_x86__mdqgnx93n4wtt\hardware\tools\avr -verbose C:\code\arduino\myblink\myblink.ino
Using board 'mega' from platform in folder: C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.39.0_x86__mdqgnx93n4wtt\hardware\arduino\avr
Using core 'arduino' from platform in folder: C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.39.0_x86__mdqgnx93n4wtt\hardware\arduino\avr
Detecting libraries used...
Error compiling for board Arduino Mega or Mega 2560.
I've seen a few people suggest similar problems but not seen any solutions that worked. One suggested changing compiler.cache_core to false in the preference file but that didn't help - I saw the same behaviour. (To be 100% sure, I closed the IDE then saved the preference file, then did the test then closed the IDE and confirmed the configuration file hadn't been reverted).
Any help gratefully received. At the moment, I'm just shutting down the IDE and restarting for each compile which works fine but I'd prefer not to do that longer term! Thanks for taking the time to read this message
I started a new program (writing messages to an LCD screen). Saw the same behaviour so I'm pretty sure the problem is with the IDE and note the code. - first compile succeeds, second fails with the error above.
My sketch is below but this was true with the "Examples -> 01.Basics -> Blink" example straight out of the box.
I'll try reinstalling with the non Windows app store version and see whether that changes things.
/*
Blink
Turns an LED on for one second, then off for one second, repeatedly.
Most Arduinos have an on-board LED you can control. On the UNO, MEGA and ZERO
it is attached to digital pin 13, on MKR1000 on pin 6. LED_BUILTIN is set to
the correct LED pin independent of which board is used.
If you want to know what pin the on-board LED is connected to on your Arduino
model, check the Technical Specs of your board at:
https://www.arduino.cc/en/Main/Products
modified 8 May 2014
by Scott Fitzgerald
modified 2 Sep 2016
by Arturo Guadalupi
modified 8 Sep 2016
by Colby Newman
This example code is in the public domain.
http://www.arduino.cc/en/Tutorial/Blink
*/
// the setup function runs once when you press reset or power the board
void setup() {
// initialize digital pin LED_BUILTIN as an output.
pinMode(LED_BUILTIN, OUTPUT);
}
// the loop function runs over and over again forever
void loop() {
digitalWrite(LED_BUILTIN, HIGH); // turn the LED on (HIGH is the voltage level)
delay(2000); // wait for a second
digitalWrite(LED_BUILTIN, LOW); // turn the LED off by making the voltage LOW
delay(50); // wait for a second
}
Tried reinstalling and I get the same behaviour. Compiles the right the first time but then fails the second. Closing and reopening resets things - the second time round it fails to compile again. Details below.
(I say compile but if I choose to upload and compile in a single step, I can successfully upload my program to the Arduino).
Setting an explicit build.path directory in preferences causes the problem not to go away on restart
If I clear out that temporary directory while the program is running then the next compile will work
The only file that really matters is "includes.cache". If I leave that and delete everything else, the compile fails. If I delete that, then the compile works
I guess there's a temporary cache directory created by Java while it's running and, the next time it starts up, that's thrown away in favour of a new directory. If I create a permanent directory, that doesn't happen so the files hang around and the compile breaks until I manually delete the directory contents.
Is it your own personal computer ?
What security do you currently have installed for antivirus etc. ?
Was your install to a local drive or cloud / network ?
(For what it's worth, it's not a major issue for me. I've got a utility that clears out the directory ready for a rebuild so it doesn't really get in the way and I've got used to having to run that every compile. I'm experienced enough at coding and the code is simple enough that it's not slowing me down much)
OK a "work computer" may be part of the issue as it may have a policy in place.
Do you have complete ADMINISTRATOR control of that machine (not just a user with some lesser admin rights) ?
It has been seen in the past that work computers have caused similar types of issue.
May not be that but if you have another computer free of work restrictions it may be worth comparing.
I'm an administrator on the PC so I wouldn't expect that to be a problem. (To be precise, I'm in the Administrators Group so I can install programs as I see fit etc).
Unfortunately, this is the only PC I can use at the moment so I can't test it out elsewhere - I'm pretty sure that I'd see something similar.
I guess I'll live with it for now - it's not very painful.
Thanks for your help @ballscrewbob. Really appreciate you taking the time to look at the problem even if we haven't resolved it.
There is a difference between "administrators group" and a machines "administrator"
There may still be a company "policy" in place on the machine which has other restrictions.
Thanks kenferguson for this and thanks for the includes.cache tip.
I can confirm the same findings. I am also running Arduino on a PC with policies and administrative rights. Running Arduino as administrator also doesn't help.
The same hardware and program work fine on a computer that I have full control over.