Compiling error - HELP! [Solved]


(Catriona) #1

Hi all,

I’m still working through the tutorials and I’ve come across an issue with compiling. I first had error messages about my last else statement which was because of a closed bracket in the wrong place, but now I think I have cleared that issue it throws up this fatal error.

I saw a couple of months ago that people were getting “error: lto-wrapper failed” errors but this was for all programs. I tested with the hello world sample code and it was fine.

Any suggestions?

Arduino: 1.8.8 (Windows Store 1.8.19.0) (Windows 10), Board: “Arduboy”

C:\Users\catri\Documents\Arduino\libraries\Arduboy2\src\Arduboy2Core.cpp: In function ‘buttonsState’:

C:\Users\catri\Documents\Arduino\libraries\Arduboy2\src\Arduboy2Core.cpp:556: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
Error compiling for board Arduboy.

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


Game & watch Parachute classic game 100% finished
(Pharap) #2

Does this still happen if you restart the IDE?
And does it still happen if you reboot the computer?

This is almost certainly a bug in the IDE or the compiler,
but the question is ‘how frequent is it?’.

A ‘segmentation fault’ means that the compiler is reading memory it shouldn’t be reading,
which usually means it’s trying to dereference an invalid pointer or there’s a buffer overrun.

I haven’t seen anyone using Arduino 1.8.8 before,
so it might be an Arduino 1.8.8-specific bug,
or it might be specific to the Windows Store version.


(Catriona) #3

It does still happen when I restart the IDE and also the laptop. I was able to compile other programs and also the earlier part of the tutorial I was working on (though I didn’t try stripping out the new parts of code an recompiling an earlier part of the lesson).

It only seems to be happening with this one program

Should I try a different version of the IDE?


(Pharap) #4

What is the program?

If we know what it is, some of us with a different IDE version could try to compile it to check if it’s the version.


(Catriona) #5

It’s the end of crait’s Lesson 4 - number guessing game.


(Catriona) #6

here is the code I wrote, just in case it is something i’ve messed up…

#include <SPI.h>
#include <Arduboy2.h>
Arduboy2 arduboy;
int playerwin;
int attempts;
int guessednumber;
int randomnumber;
int upbuffer;
int downbuffer;
int abuffer;
int lastguess;

void setup() {

arduboy.begin();
arduboy.clear();
playerwin = 0;
attempts = 0;
guessednumber = 0;
arduboy.initRandomSeed ();
randomnumber = random(1, 101);
upbuffer = 0;
downbuffer = 0;
abuffer = 0;
lastguess = 0;

}

void loop() {
arduboy.clear();

if(playerwin == 0){ //game not won so start game

    if(attempts == 7){  //game over
        arduboy.print("You Lost!");
        arduboy.print("\n");
        arduboy.print("Correct Number: ");
        arduboy.print(randomnumber);
        if(arduboy.pressed(A_BUTTON) == true and abuffer == 0){
          abuffer = 1;
          randomnumber = random(1, 101);
          attempts = 0;
          playerwin = 0;
        }
    
    }
    else { //player has more attempts
 
      if(arduboy.pressed(UP_BUTTON) == true and upbuffer == 0){ // increase selected number to guess
          upbuffer = 1;
          guessednumber++;
      }
        
      if(arduboy.pressed(DOWN_BUTTON) == true and downbuffer == 0){  // decrease selected number to guess
          downbuffer = 1;
          guessednumber--;
      }

      if(arduboy.pressed(A_BUTTON) == true and abuffer == 0){  // // try guessed number
          abuffer = 1;
          if(guessednumber == randomnumber){  // you win
          playerwin = 1;
          }

          else{  // failed attempt
            ++attempts;
            lastguess = guessednumber; 
          }
       }
          
     arduboy.print("Attempt: ");
     arduboy.print(attempts);
     arduboy.print("\n");
     arduboy.print("Number to guess: ");
     arduboy.print(guessednumber);
     arduboy.print("\n");
     if (attempts == 0){
       arduboy.print("Good Luck!"); //no last guess
     }
     else{
       arduboy.print(lastguess);
       if (lastguess > randomnumber){
        arduboy.print(" is too high!");
       }
       if (lastguess < randomnumber){
        arduboy.print(" is too low!");        
       }
     }
   }   
}
else{
  arduboy.print("You Won");
  arduboy.print("\n");
  arduboy.print("Correct Number: ");
  arduboy.print(randomnumber);
   if(arduboy.pressed(A_BUTTON) == true and abuffer == 0){
          abuffer = 1;
          randomnumber = random(1, 101);
          attempts = 0;
          playerwin = 0;
   }
   
  }
if(arduboy.notPressed(A_BUTTON) == true){
  abuffer = 0;
}
if(arduboy.notPressed(UP_BUTTON) == true){
  upbuffer = 0;
}
if(arduboy.notPressed(DOWN_BUTTON) == true){
  downbuffer = 0;
}


arduboy.display();

}

(Scott) #7

@Catriona,

I’ve formatted the code that you posted by enclosing it as a code block. In the future, please do so yourself:

Put a line with three backticks and cpp before the first line of your code.
Put a line with three backticks after the last line of your code:

```cpp
Your code goes here.
```


(Catriona) #8

thanks, I tried to find instructions on how to do this as I could see other people doing it, but I couldn’t find anything. You only know what you know. :blush:


(Pharap) #9

It compiles fine for me on Arduino IDE 1.8.5,
so it’s definitely either a bug with the Arduino IDE 1.8.8,
a bug with the Windows Store version,
or a bug with your particular installation.
(Sometimes the Arduino IDE doesn’t install correctly and reintalling fixes it.)

I’d recommend downgrading to an earlier version.


(Pharap) #10

(We really ought to have a “recommended reading for beginners” section to put this in…)


(Catriona) #11

Thanks Pharap, I downloaded from the Arduino website rather than the windows store but it might be the same versions. I will uninstall and try the earlier version.


(Scott) #12

It compiles without errors for me, with IDE 1.8.8 under Ubuntu Linux 16.04


(Catriona) #13

thanks guys, I uninstalled the latest version and installed 1.8.5 and it now compiles fine. :+1::metal:


(Pharap) #14

My guess is it’s either a problem with the 1.8.8 version for Windows or it just didn’t install correctly.

Either way it’s fixed now.

It might be worth trying to upgrade again at a later date to see if the problem has been fixed (assuming it was a problem with the actual version and not the installation - it’s surprising how often the Arduino IDE doesn’t install correctly).