Internal compiler error: Segmentation fault

Hi,

Working on setting a sketch for hydroponic control , i added some line for LCD shield , then got this error;

Arduino:1.8.9 (Windows Store 1.8.21.0) (Windows 10), Carte : "Arduino/Genuino Mega or Mega 2560, ATmega2560 (Mega 2560)"

C:\Users\rogmo\Documents\Arduino\libraries\LiquidCrystal\src\LiquidCrystal.cpp: In member function 'pulseEnable':

C:\Users\rogmo\Documents\Arduino\libraries\LiquidCrystal\src\LiquidCrystal.cpp:311: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.21.0_x86__mdqgnx93n4wtt\hardware\tools\avr/bin/avr-gcc returned 1 exit status

compilation terminated.

c:/program files/windowsapps/arduinollc.arduinoide_1.8.21.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

Plusieurs bibliothèque trouvées pour "LiquidCrystal.h"
Utilisé : C:\Users\rogmo\Documents\Arduino\libraries\LiquidCrystal
Non utilisé : C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.21.0_x86__mdqgnx93n4wtt\libraries\LiquidCrystal
exit status 1
Erreur de compilation pour la carte Arduino/Genuino Mega or Mega 2560

Ce rapport pourrait être plus détaillé avec
l'option "Afficher les résultats détaillés de la compilation"
activée dans Fichier -> Préférences.

Here is the code of the sketch for hydroponic that does not compile, I have also tried a code for Detecbutton using the same librairy :
#include <LiquidCrystal.h>, and it work, it compile and the code work.

Thanks,

/*
#####################################################################################
#  	File:               Arduino_Watering_sustem.ino                                             
#       Processor:          Arduino UNO, MEGA ou Teensy++ 2.0      
#  	Language:	    Wiring / C /Processing /Fritzing / Arduino IDE          
#						
#	Objectives:         Watering System - Irrigation
#										  
#	Behavior:	    When the soil is dry,
#                           
#
#			
#   Author:                 Marcelo Moraes 
#   Date:                   12/10/12	
#   place:                  Brazil, Sorocaba City	
#					
#####################################################################################
 
  This project contains public domain code.
  The modification is allowed without notice.
  
 */

// libraries definition
#include <Wire.h>
#include <LiquidCrystal.h>
#include <RTClib.h>



// frequency musical notes
#define NOTE_C6  1047
#define NOTE_C3  131
#define NOTE_G3  196

// pins definition
int levelSensorPin = A14;
int moistureSensorPin = A8;
int audioPin = 45;
int soggyLEDPin = 42;
int moistsoilLEDPin = 43;
int drysoilLEDPin = 44;
int pumpLEDPin = 41;
int pumpPin = 46;

// variables
int levelSensorValue;       // stores the level sensor values
int moistureSensorValue;    // stores the moisture sensor values
int j = 0;

/*// system messages
const char *string_table[] =
{   
  "     Welcome! =)",
  "   Tank LOW level",
  "      Dry soil",
  "     Moist soil",
  "     Soggy soil",
  "The water pump is on",
  "   ArduinoByMyself",
  "   Watering System",
  "    Please wait!"
};*/

//LCD pin to Arduino
const int pin_RS = 8; 
const int pin_EN = 9; 
const int pin_d4 = 4; 
const int pin_d5 = 5; 
const int pin_d6 = 6; 
const int pin_d7 = 7; 

const int pin_BL = 10;

// objects definition

LiquidCrystal lcd( pin_RS,  pin_EN,  pin_d4,  pin_d5,  pin_d6,  pin_d7);
DS3231 RTC;


void setup(){
  // serial initialization
  Serial.begin(9600);
  
  // Wire initialization
  Wire.begin();
  
  // RTC initialization
  RTC.begin();
  if (!RTC.isrunning()){
    // date and time adjust as the PC computer date and time
    RTC.adjust(DateTime(__DATE__, __TIME__)); 
  }
  
  // Arduino pins initalization
  pinMode(audioPin, OUTPUT);
  pinMode(soggyLEDPin, OUTPUT);
  pinMode(moistsoilLEDPin,OUTPUT);
  pinMode(drysoilLEDPin,OUTPUT);
  pinMode(pumpLEDPin,OUTPUT);
  pinMode(pumpPin,OUTPUT);
  
 /*// LCD initial messages
  lcd.clear();
  lcd.setCursor(0,0);
  lcd.print(string_table[6]); 
  lcd.setCursor(0,1);
  lcd.print(string_table[7]); 
  lcd.setCursor(0,3);
  lcd.print(string_table[0]);*/

// LCD initialisation see detectbutton_code1

 lcd.begin(16, 2);
 lcd.clear();
 lcd.setCursor(0,0);
 lcd.print("Electropeak.com");
 lcd.setCursor(0,1);
 lcd.print("Press Key:");  
  // initialization delay
  delay(5000); 
}

void loop(){
  
  
  // RTC parameters definition
  DateTime myRTC = RTC.now();
  int H = myRTC.hour();
  int M = myRTC.minute();
  int S = myRTC.second();
  
  // call Clock Function
  //RightHour();
  
  // reads the sensors
  levelSensorValue = analogRead(levelSensorPin);
  moistureSensorValue = analogRead(moistureSensorPin);
  
  // if low water level: plays the low level alarm
  if(levelSensorValue > 600){
    // system messages
    lcd.clear();
    RightHour();
    lcd.setCursor(0,3);
    lcd.print("Tank LOW level"); 
    // plays the alarm sound
    for(int i=0;i<2;i++){
      tone(audioPin, NOTE_G3, 200);
      delay(200);
      tone(audioPin, NOTE_C3, 200);
      delay(200);
      noTone(audioPin);
    }
  }
  
  // check the moisture range
  if(moistureSensorValue >= 700){
    // in case of dry soil:
    // system messages
    lcd.clear();
    RightHour();
    lcd.setCursor(0,3);
    lcd.print(" Dry soil");
    // lights up the correct LED
    digitalWrite(drysoilLEDPin,HIGH);
    digitalWrite(moistsoilLEDPin,LOW);
    digitalWrite(soggyLEDPin,LOW);
    // plays the alarm sound
    tone(audioPin, NOTE_C6, 100);
    delay(250);
    noTone(audioPin);
  }
  if((moistureSensorValue < 700) && (moistureSensorValue >= 300)){
    // in case of moist soil:
    // system messages
    lcd.clear();
    RightHour();
    lcd.setCursor(0,3);
    lcd.print(" Moist soil");
    // lights up the correct LED
    digitalWrite(drysoilLEDPin,LOW);
    digitalWrite(moistsoilLEDPin,HIGH);
    digitalWrite(soggyLEDPin,LOW);
    delay(250);
  }
  if(moistureSensorValue < 300){
    // in case of soggy soil:
    // system messages
    lcd.clear();
    RightHour();
    lcd.setCursor(0,3);
    lcd.print( " Soggy soil"); 
    // lights up the correct LED
    digitalWrite(drysoilLEDPin,LOW);
    digitalWrite(moistsoilLEDPin,LOW);
    digitalWrite(soggyLEDPin,HIGH);
    delay(100);
  }
  
  // if the soil is dry and if it is the right time: turn on the pump for 1 minute
  if((H == 16) && (M == 50) && (S == 00)){
    while(moistureSensorValue >= 700){
      // system messages
      lcd.clear();
      RightHour();
      lcd.setCursor(0,1);
      lcd.print("  Please wait!");
      lcd.setCursor(0,3);
      lcd.print("water pump on");
      // turn the pump on
      digitalWrite(pumpPin,HIGH);
      digitalWrite(pumpLEDPin,HIGH);
      delay(10000);
      // if the soil is not moist so far
      // reads the moisture sensor once more
      moistureSensorValue = analogRead(moistureSensorPin);
    }
    // turn the pump off
    digitalWrite(pumpPin,LOW);
    digitalWrite(pumpLEDPin,LOW);
  }
  
}

// Real Time Clock Function
void RightHour()
{
  DateTime Now = RTC.now();
  String clock_date = "  Date: ";
  String clock_hour = "   Time: ";
  
  int _day = Now.day();
  int _month = Now.month();
  int _year = Now.year();
  
  clock_date += fixZero(_day);
  clock_date += "/";
  clock_date += fixZero(_month);
  clock_date += "/";
  clock_date += _year;
  
  int _hour = Now.hour();
  int _minute = Now.minute();
  int _second = Now.second();
  
  clock_hour += fixZero(_hour);
  clock_hour += ":";
  clock_hour += fixZero(_minute);
  clock_hour += ":";
  clock_hour += fixZero(_second);
  
  lcd.clear();
  lcd.setCursor(0, 0);
  lcd.print(clock_date);
  lcd.setCursor(0, 1);
  lcd.print(clock_hour);
  
  delay(500);
}


String fixZero(int i)
{
  String ret;
  if (i < 10) ret += "0";
  ret += i;
  return ret;
}

Do this:

  • Tools > Board > Boards Manager
  • Wait for the download to finish.
  • Click on "Arduino AVR Boards".
  • Click the "Update" button.
  • Wait for the update to finish.
  • Click the "Close" button.

After updating, the error will no longer occur.