Erro ao compilar para a placa Arduino/Genuino Mega or Mega 2560

ESTÁ ME A DAR ESTE ERRO:

Arduino: 1.8.8 (Windows Store 1.8.19.0) (Windows 10), Placa:"Arduino/Genuino Mega or Mega 2560, ATmega2560 (Mega 2560)"

C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.19.0_x86__mdqgnx93n4wtt\hardware\arduino\avr\cores\arduino\Print.cpp: In function 'println.constprop':

C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.19.0_x86__mdqgnx93n4wtt\hardware\arduino\avr\cores\arduino\Print.cpp:136:1: internal compiler error: Segmentation fault

}

^

Please submit a full bug report,

with preprocessed source if appropriate.

See http://gcc.gnu.org/bugs.html for instructions.

lto-wrapper.exe: fatal error: C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.19.0_x86__mdqgnx93n4wtt\hardware\tools\avr/bin/avr-gcc returned 1 exit status

compilation terminated.

c:/program files/windowsapps/arduinollc.arduinoide_1.8.19.0_x86__mdqgnx93n4wtt/hardware/tools/avr/bin/../lib/gcc/avr/5.4.0/../../../../avr/bin/ld.exe: error: lto-wrapper failed

collect2.exe: error: ld returned 1 exit status

exit status 1
Erro ao compilar para a placa Arduino/Genuino Mega or Mega 2560.

Este relatório teria mais informação com a
opção «Mostrar mensagens detalhadas durante a
compilação» seleccionada nas Preferências.


O CÓDIGO É ESTE:

#include <SPI.h>
#include <SD.h>
#include <LiquidCrystal.h>

LiquidCrystal lcd(8, 9, 4, 5, 6, 7);

File root;
String legenda[100];
int j=0,i=0;

// define some values used by the panel and buttons
int lcd_key = 0;
int adc_key_in = 0;
#define btnRIGHT 0
#define btnUP 1
#define btnDOWN 2
#define btnLEFT 3
#define btnSELECT 4
#define btnNONE 5

// read the buttons
int read_LCD_buttons()
{
adc_key_in = analogRead(0);
if (adc_key_in > 1000) return btnNONE;
if (adc_key_in < 50) return btnRIGHT;
if (adc_key_in < 195) return btnUP;
if (adc_key_in < 380) return btnDOWN;
if (adc_key_in < 555) return btnLEFT;
if (adc_key_in < 790) return btnSELECT;

return btnNONE;
}

void setup() {
// Open serial communications and wait for port to open:
Serial.begin(9600);
while (!Serial) {
; // wait for serial port to connect. Needed for native USB port only
}

Serial.print("A Inicializar o cartao SD...");
Serial.println("\t");

if (!SD.begin(4)) {
Serial.println("Falha na Inicializacao.");
while (1);
}
Serial.println("Inicializacao Terminada.\n");

root = SD.open("/");

printDirectory(root, 0);

lcd.begin(16, 2);
lcd.setCursor(0,0);
lcd.print("Ficheiros:");

Serial.println("\nFIM!");
}

void loop() {
lcd.setCursor(0,1); // move to the begining of the second line
lcd_key = read_LCD_buttons(); // read the buttons

switch (lcd_key) // depending on which button was pushed, we perform an action
{

case btnUP:

if (i>0){
i--;
lcd.setCursor(0,1);
lcd.print(" ");
delay (200);
}
else {
i=j;
lcd.setCursor(0,1);
lcd.print(" ");
delay (200);
}
break;

case btnDOWN:

if (i<j){
i++;
lcd.setCursor(0,1);
lcd.print(" ");
delay (200);
}
else {
i=0;
lcd.setCursor(0,1);
lcd.print(" ");
delay (200);
}
break;

case btnSELECT:

Serial.println(legenda*);*

  • delay(200);*

  • lcd_key = read_LCD_buttons(); *

  • break;*

  • case btnNONE:*

_ lcd.print(legenda*);_
_
delay(200);_
lcd_key = read_LCD_buttons();
_
break;*_

}
}
void printDirectory(File dir, int numTabs) {
* while (true) {*
* File entry = dir.openNextFile();*
* if (! entry) {*
* // no more files*
* break;*
* } *
* legenda[j]=entry.name();*
* Serial.println(legenda[j]);*
* j++;*
}
}
-----------------
ALGUÉM QUE ME DIGA O QUE ESTÁ MAL?
OBRIGADO!!!

Tente desinstalar o Arduino IDE e instalar novamente usando o Windows Installer (e NÃO Windows App):