Error compiling of board Arduino/Genuino Mega or Mega 2560

Hi guys, I was programming and everything was working fine, when suddely this error came up. It now keeps giving this error and I can't upload my code anymore. I didn't do anything strange, just what I was doing before and then it worked.

Arduino: 1.8.1 (Windows 10), Board:"Arduino/Genuino Mega or Mega 2560, ATmega2560 (Mega 2560)"

c:/program files (x86)/arduino/hardware/tools/avr/bin/../lib/gcc/avr/4.9.2/../../../../avr/lib/avr6/crtatmega2560.o:(.init9+0x0): undefined reference to `main'

C:\Users\Lars\AppData\Local\Temp\ccT4orR8.ltrans0.ltrans.o: In function `__base_dtor ':

C:\Users\Lars\Documents\Arduino\libraries\Adafruit_NeoPixel-master/Adafruit_NeoPixel.cpp:62: undefined reference to `pinMode'

C:\Users\Lars\AppData\Local\Temp\ccT4orR8.ltrans0.ltrans.o: In function `pulseEnable':

C:\Program Files (x86)\Arduino\libraries\LiquidCrystal\src/LiquidCrystal.cpp:304: undefined reference to `digitalWrite'

C:\Program Files (x86)\Arduino\libraries\LiquidCrystal\src/LiquidCrystal.cpp:306: undefined reference to `digitalWrite'

C:\Program Files (x86)\Arduino\libraries\LiquidCrystal\src/LiquidCrystal.cpp:308: undefined reference to `digitalWrite'

C:\Users\Lars\AppData\Local\Temp\ccT4orR8.ltrans0.ltrans.o: In function `write4bits':

C:\Program Files (x86)\Arduino\libraries\LiquidCrystal\src/LiquidCrystal.cpp:314: undefined reference to `digitalWrite'

C:\Users\Lars\AppData\Local\Temp\ccT4orR8.ltrans0.ltrans.o: In function `send':

C:\Program Files (x86)\Arduino\libraries\LiquidCrystal\src/LiquidCrystal.cpp:288: undefined reference to `digitalWrite'

C:\Users\Lars\AppData\Local\Temp\ccT4orR8.ltrans0.ltrans.o:C:\Program Files (x86)\Arduino\libraries\LiquidCrystal\src/LiquidCrystal.cpp:291: more undefined references to `digitalWrite' follow

C:\Users\Lars\AppData\Local\Temp\ccT4orR8.ltrans0.ltrans.o: In function `updateLength':

C:\Users\Lars\Documents\Arduino\libraries\Adafruit_NeoPixel-master/Adafruit_NeoPixel.cpp:81: undefined reference to `pinMode'

C:\Users\Lars\AppData\Local\Temp\ccT4orR8.ltrans0.ltrans.o: In function `setPin':

C:\Users\Lars\Documents\Arduino\libraries\Adafruit_NeoPixel-master/Adafruit_NeoPixel.cpp:1530: undefined reference to `digitalWrite'

C:\Users\Lars\Documents\Arduino\libraries\Adafruit_NeoPixel-master/Adafruit_NeoPixel.cpp:1531: undefined reference to `digital_pin_to_port_PGM'

C:\Users\Lars\Documents\Arduino\libraries\Adafruit_NeoPixel-master/Adafruit_NeoPixel.cpp:1532: undefined reference to `digital_pin_to_port_PGM'

C:\Users\Lars\Documents\Arduino\libraries\Adafruit_NeoPixel-master/Adafruit_NeoPixel.cpp:1535: undefined reference to `port_to_output_PGM'

C:\Users\Lars\Documents\Arduino\libraries\Adafruit_NeoPixel-master/Adafruit_NeoPixel.cpp:1535: undefined reference to `port_to_output_PGM'

C:\Users\Lars\Documents\Arduino\libraries\Adafruit_NeoPixel-master/Adafruit_NeoPixel.cpp:1535: undefined reference to `digital_pin_to_bit_mask_PGM'

C:\Users\Lars\Documents\Arduino\libraries\Adafruit_NeoPixel-master/Adafruit_NeoPixel.cpp:1535: undefined reference to `digital_pin_to_bit_mask_PGM'

C:\Users\Lars\AppData\Local\Temp\ccT4orR8.ltrans0.ltrans.o: In function `__static_initialization_and_destruction_0':

C:\Users\Lars\Documents\School\Art Projects\DVD_ResponsiveV4/DVD_ResponsiveV4.ino:65: undefined reference to `digital_pin_to_bit_mask_PGM'

C:\Users\Lars\Documents\School\Art Projects\DVD_ResponsiveV4/DVD_ResponsiveV4.ino:65: undefined reference to `digital_pin_to_bit_mask_PGM'

C:\Users\Lars\Documents\School\Art Projects\DVD_ResponsiveV4/DVD_ResponsiveV4.ino:64: undefined reference to `digital_pin_to_bit_mask_PGM'

C:\Users\Lars\AppData\Local\Temp\ccT4orR8.ltrans0.ltrans.o:C:\Users\Lars\Documents\School\Art Projects\DVD_ResponsiveV4/DVD_ResponsiveV4.ino:64: more undefined references to `digital_pin_to_bit_mask_PGM' follow

C:\Users\Lars\AppData\Local\Temp\ccT4orR8.ltrans0.ltrans.o: In function `__base_ctor ':

C:\Users\Lars\Documents\Arduino\libraries\NewPing/NewPing.cpp:20: undefined reference to `digital_pin_to_port_PGM'

C:\Users\Lars\Documents\Arduino\libraries\NewPing/NewPing.cpp:20: undefined reference to `digital_pin_to_port_PGM'

C:\Users\Lars\Documents\Arduino\libraries\NewPing/NewPing.cpp:20: undefined reference to `port_to_output_PGM'

C:\Users\Lars\Documents\Arduino\libraries\NewPing/NewPing.cpp:20: undefined reference to `port_to_output_PGM'

C:\Users\Lars\Documents\Arduino\libraries\NewPing/NewPing.cpp:21: undefined reference to `digital_pin_to_port_PGM'

C:\Users\Lars\Documents\Arduino\libraries\NewPing/NewPing.cpp:21: undefined reference to `digital_pin_to_port_PGM'

C:\Users\Lars\Documents\Arduino\libraries\NewPing/NewPing.cpp:21: undefined reference to `port_to_input_PGM'

C:\Users\Lars\Documents\Arduino\libraries\NewPing/NewPing.cpp:21: undefined reference to `port_to_input_PGM'

C:\Users\Lars\Documents\Arduino\libraries\NewPing/NewPing.cpp:23: undefined reference to `port_to_mode_PGM'

C:\Users\Lars\Documents\Arduino\libraries\NewPing/NewPing.cpp:23: undefined reference to `port_to_mode_PGM'

C:\Users\Lars\AppData\Local\Temp\ccT4orR8.ltrans0.ltrans.o: In function `begin':

C:\Program Files (x86)\Arduino\libraries\LiquidCrystal\src/LiquidCrystal.cpp:91: undefined reference to `pinMode'

C:\Program Files (x86)\Arduino\libraries\LiquidCrystal\src/LiquidCrystal.cpp:94: undefined reference to `pinMode'

C:\Program Files (x86)\Arduino\libraries\LiquidCrystal\src/LiquidCrystal.cpp:96: undefined reference to `pinMode'

C:\Program Files (x86)\Arduino\libraries\LiquidCrystal\src/LiquidCrystal.cpp:101: undefined reference to `pinMode'

C:\Program Files (x86)\Arduino\libraries\LiquidCrystal\src/LiquidCrystal.cpp:109: undefined reference to `digitalWrite'

C:\Program Files (x86)\Arduino\libraries\LiquidCrystal\src/LiquidCrystal.cpp:110: undefined reference to `digitalWrite'

C:\Program Files (x86)\Arduino\libraries\LiquidCrystal\src/LiquidCrystal.cpp:112: undefined reference to `digitalWrite'

C:\Users\Lars\AppData\Local\Temp\ccT4orR8.ltrans0.ltrans.o:(.rodata+0x6): undefined reference to `Print::write(unsigned char const*, unsigned int)'

collect2.exe: error: ld returned 1 exit status

exit status 1
Fout bij het compileren van board Arduino/Genuino Mega or Mega 2560
Ongeldige bibliotheek gevonden in C:\Users\Lars\Documents\Arduino\libraries\MechHart-_1_-_V1: C:\Users\Lars\Documents\Arduino\libraries\MechHart-_1_-_V1
Ongeldige bibliotheek gevonden in C:\Users\Lars\Documents\Arduino\libraries\PulseSenor: C:\Users\Lars\Documents\Arduino\libraries\PulseSenor
Ongeldige bibliotheek gevonden in C:\Users\Lars\Documents\Arduino\libraries\MechHart-_1_-_V1: C:\Users\Lars\Documents\Arduino\libraries\MechHart-_1_-_V1
Ongeldige bibliotheek gevonden in C:\Users\Lars\Documents\Arduino\libraries\PulseSenor: C:\Users\Lars\Documents\Arduino\libraries\PulseSenor

This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.

Try restarting the Arduino IDE. It's possible that something got messed up with the cached code and that will clear the cache.

I'm running into a similar issue today as well. Yesterday the sketch compiled. Today all kinds of errors contained in library functions with references to digitalWrite, millis and String character constants. Interestingly, the errors reported differ from time-to-time. Then, after many attempts, occasionally the sketch will compile OK.

I did make a change over the weekend. I got a new laptop PC, and installed the Arduino IDE on it. The symptoms first showed up on the laptop, so I went back to my desktop and got similar error reports there.

Then, after the errors started appearing I noticed that there was an upgrade available for the SD library so I installed it (version 1.1.1 to 1.2.0).

I've restarted both IDEs, but not reinstalled.

I'm still getting the pesky failure to compile for Mega 2560 (see ...bin\avr-ar: unable to rename 'core.a'; reason: File exists - Programming Questions - Arduino Forum), FWIW. Don't know if these are reated.

I'm still getting the pesky failure to compile for Mega 2560

Did you not notice how the previous poster gave the actual error text instead of trying to paraphrase it? There's a lot more that can be told from the full message.

If you're getting failure to compile and not a linker error then it definitely isn't the same error as the previous one on this thread.

So, here's the pesky failure to compile for Mega 2560 that I mentioned is addressed in the Forum at ...bin\avr-ar: unable to rename 'core.a'; reason: File exists - Programming Questions - Arduino Forum

:\users\ron\appdata\local\arduino15\packages\arduino\tools\avr-gcc\4.9.2-atmel3.5.4-arduino2\bin\../lib/gcc/avr/4.9.2/../../../../avr/bin/ar.exe: unable to rename 'core\core.a'; reason: File exists

Multiple libraries were found for "SD.h"
 Used: C:\Users\Ron\Documents\Arduino\libraries\SD
 Not used: C:\Program Files (x86)\Arduino\libraries\SD
exit status 1
Error compiling for board Arduino/Genuino Mega or Mega 2560.

As mentioned in that post, after 2-3-4 attempts it compiles just fine with no other changes.

unable to rename 'core\core.a'; reason: File exists

Have you tried hunting it down and making it so it doesn't exist?

I followed the path and found the ar.exe file, but there is no core or core.a file in that folder. So I searched from the Arduino15 folder on down for anything that had 'core' in its name; two folders were found, 'core' and 'cores'; they both contained a folder and files. There was no 'core.a'. So, I'm not sure that I should be deleting either of these, as they may not be the things being complained about (no pathname is given for core/core.a; the pathname is only for ar.exe).

The above issue, however, is just the pesky issue. That one is overcome simply by compiling multiple times until the compile eventually succeeds with no code change required.

The main issue in this thread is the new errors being reported, presumably contained in libraries that we have successfully referenced before. The error messages I receive are as follows:

Arduino: 1.8.5 (Windows 10), Board: "Arduino/Genuino Mega or Mega 2560, ATmega2560 (Mega 2560)"

C:\Users\ron_b\AppData\Local\Temp\ccsTCEwJ.ltrans0.ltrans.o: In function `Sd2Card::waitNotBusy(unsigned int)':

ccsTCEwJ.ltrans0.o:(.text+0x15a): undefined reference to `millis'

ccsTCEwJ.ltrans0.o:(.text+0x166): undefined reference to `millis'

ccsTCEwJ.ltrans0.o:(.text+0x18a): undefined reference to `digitalWrite'

C:\Users\ron_b\AppData\Local\Temp\ccsTCEwJ.ltrans0.ltrans.o: In function `Sd2Card::cardCommand(unsigned char, unsigned long)':

ccsTCEwJ.ltrans0.o:(.text+0x21e): undefined reference to `digitalWrite'

C:\Users\ron_b\AppData\Local\Temp\ccsTCEwJ.ltrans0.ltrans.o: In function `Sd2Card::readData(unsigned long, unsigned int, unsigned int, unsigned char*) [clone .part.6]':

ccsTCEwJ.ltrans0.o:(.text+0x328): undefined reference to `millis'

ccsTCEwJ.ltrans0.o:(.text+0x336): undefined reference to `millis'

C:\Users\ron_b\AppData\Local\Temp\ccsTCEwJ.ltrans0.ltrans.o: In function `global constructors keyed to 65535_0_Core2017_008.ino.cpp.o.2857':

ccsTCEwJ.ltrans0.o:(.text.startup+0x8c): undefined reference to `String::String(char const*)'

ccsTCEwJ.ltrans0.o:(.text.startup+0xbe): undefined reference to `String::String(char const*)'

C:\Users\ron_b\AppData\Local\Temp\ccsTCEwJ.ltrans0.ltrans.o: In function `_GLOBAL__sub_D_LightCommands':

ccsTCEwJ.ltrans0.o:(.text.exit+0x4): undefined reference to `String::~String()'

ccsTCEwJ.ltrans0.o:(.text.exit+0xc): undefined reference to `String::~String()'

C:\Users\ron_b\AppData\Local\Temp\ccsTCEwJ.ltrans0.ltrans.o:(.rodata+0x18): undefined reference to `Print::write(unsigned char const*, unsigned int)'

c:/program files (x86)/arduino/hardware/tools/avr/bin/../lib/gcc/avr/4.9.2/../../../../avr/lib/avr6/crtatmega2560.o:(.init9+0x0): undefined reference to `main'

collect2.exe: error: ld returned 1 exit status

Multiple libraries were found for "SD.h"
 Used: C:\Users\ron_b\Documents\Arduino\libraries\SD
 Not used: C:\Program Files (x86)\Arduino\libraries\SD
exit status 1
Error compiling for board Arduino/Genuino Mega or Mega 2560.

This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.