marcellatwin
Posts: 31
Joined: Sat Jan 27, 2018 6:41 pm
Location: USA

Can't Compile Any More! Please need help!

Sat May 25, 2019 12:34 am

Hello there. I hope you guys can help me cause I am pulling my hair out trying to figure this out. I keep getting a Segmentation fault when I compile.

Here is the error:

Code: Select all

collect2: error: ld terminated with signal 11 [Segmentation fault]
So some context... I'm running a Raspberry Pi 3B with Debian Stretch. I've been using the Pi since I bought it for a project for an active exhaust on my car with a CAN shield. Here's the project: viewtopic.php?t=220138

At my internship, they ask me to do something similar to my personal project for them. So while waiting for the new 3B+ I had them order to get in I decided to work on my personal Pi to get the software ready. Everything has been fine and compiling. One day I finally decided to update my Pi from Jessie to Stretch. Once I did that, I'm not sure when but seems like really soon the compiling started throwing up the error above. At first I thought it was the new code I was writing for the project, since I was doing some things I haven't done before. But after getting the same error after 3 days of trying different things I tried to compile my personal project code, which hasn't changed and it errored out.

All the reading I've done sorta hinted at a possible bug in gcc version 6. So I installed an earlier version of gcc (from Jessie), 4.9. It still errored out. I thought maybe it was my code, so I wrote a super simple Hello World seen here:

Code: Select all

// Hello World
#include <stdio.h>

int main(void)
{
	printf("Hello World!\n");
	return 0;
}
Even this still ended up like this:

Code: Select all

[email protected]:~ $ gcc hello_test.c
collect2: error: ld terminated with signal 11 [Segmentation fault]
So now I KNOW that it isn't me and something is wrong with the compilation, or should I say the linker (ld) is having issues. The only thing I can think of is Stretch has issues, but would that effect gcc? Even with going to the Jessie version of gcc (4.9)? Does anybody have any suggestions or advice cause it is driving me crazy and starting to effect my internship?

Thanks in advanced.

dl324
Posts: 107
Joined: Mon May 06, 2019 7:33 pm
Location: Pacific Northwest, USA

Re: Can't Compile Any More! Please need help!

Sat May 25, 2019 1:53 am

I'm not having any problems with Stretch.

Code: Select all

gcc version 6.3.0 20170516 (Raspbian 6.3.0-18+rpi1+deb9u1) 
36 pi> ld -v
GNU ld (GNU Binutils for Raspbian) 2.28
Since 'ld' is having problems, you could try removing and re-installing binutils.

marcellatwin
Posts: 31
Joined: Sat Jan 27, 2018 6:41 pm
Location: USA

Re: Can't Compile Any More! Please need help!

Sat May 25, 2019 3:09 am

So going off your advice I did the following:

Code: Select all

sudo apt purge binutils
sudo apt install binutils
Which seemed to get ride of gcc entirely, both versions. Could you tell me briefly what is binutils, or what it contains?

I then did:

Code: Select all

sudo apt autoremove
sudo apt install gcc
...
gcc version 6.3.0 20170516 (Raspbian 6.3.0-18+rpi1+deb9u1) 
GNU ld (GNU Binutils for Raspbian) 2.28
So I now have the same version as yours and it looks like it works!!!
Thank you so much. It was really driving me crazy.
So what exactly do you think happened? I do vaguely remember during the update to Stretch, at some point it failed then I restarted the install, maybe that was what caused it...

I do notice now that the CodeBlocks I installed is gone. I thought I saw something related to in in the purge or autoremove lists. Guess I'll have to reinstall it as well.

pfletch101
Posts: 423
Joined: Sat Feb 24, 2018 4:09 am

Re: Can't Compile Any More! Please need help!

Sat May 25, 2019 2:54 pm

Upgrading (in place) a system to Stretch is an iffy process. When I tried it, last year, I encountered all sorts of issues. The usual recommendation is to burn the latest version of Stretch to a new SD card and then reconfigure it to your taste. The time that this takes is (for most people) well worth it, in terms of the stability of the ultimate 'product'.

marcellatwin
Posts: 31
Joined: Sat Jan 27, 2018 6:41 pm
Location: USA

Re: Can't Compile Any More! Please need help!

Sun May 26, 2019 4:08 pm

pfletch101 wrote: Upgrading (in place) a system to Stretch is an iffy process. When I tried it, last year, I encountered all sorts of issues. The usual recommendation is to burn the latest version of Stretch to a new SD card and then reconfigure it to your taste. The time that this takes is (for most people) well worth it, in terms of the stability of the ultimate 'product'.
So just so I understand, cause I'm still fairly new to the Pi and mostly self-taught when it come to specifically the Pi so I miss things sometimes, but you mean to wipe clean the SD (reformat), burn a brand new copy of Stretch, then reinstall any programs/libraries and reconfigure everything to get it back to where you left off (vnc settings, ssh settings, etc.)?? Wow that does sound like a lot of work.

Ernst
Posts: 1078
Joined: Sat Feb 04, 2017 9:39 am
Location: Germany

Re: Can't Compile Any More! Please need help!

Sun May 26, 2019 4:28 pm

marcellatwin wrote:
Sun May 26, 2019 4:08 pm
pfletch101 wrote: Upgrading (in place) a system to Stretch is an iffy process. When I tried it, last year, I encountered all sorts of issues. The usual recommendation is to burn the latest version of Stretch to a new SD card and then reconfigure it to your taste. The time that this takes is (for most people) well worth it, in terms of the stability of the ultimate 'product'.
So just so I understand, cause I'm still fairly new to the Pi and mostly self-taught when it come to specifically the Pi so I miss things sometimes, but you mean to wipe clean the SD (reformat), burn a brand new copy of Stretch, then reinstall any programs/libraries and reconfigure everything to get it back to where you left off (vnc settings, ssh settings, etc.)?? Wow that does sound like a lot of work.
There is an even better way to upgrade:
- freeze the environment on your current system, that means no more updates
- buy a new raspberry and a new memory card
- install a new copy of stretch
- install and configure whatever you need
- transfer anything you need from the current system to the new system.
- shutdown your old system into sleep mode (meaning put it away without power) to be used for the buster upgrade (RSN)

It may sound a lot but I can guarantee that you will learn more this way.
The road to insanity is paved with static ip addresses

dl324
Posts: 107
Joined: Mon May 06, 2019 7:33 pm
Location: Pacific Northwest, USA

Re: Can't Compile Any More! Please need help!

Sun May 26, 2019 4:32 pm

marcellatwin wrote:
Sun May 26, 2019 4:08 pm
So just so I understand, cause I'm still fairly new to the Pi and mostly self-taught when it come to specifically the Pi so I miss things sometimes,
Most of us are in the same situation. It's not like we're going to take a class to learn how to use RPi's. As with most things related to computers or programing, there's more than one way to accomplish a task.
but you mean to wipe clean the SD (reformat), burn a brand new copy of Stretch, then reinstall any programs/libraries and reconfigure everything to get it back to where you left off (vnc settings, ssh settings, etc.)?? Wow that does sound like a lot of work.
Ideally upgrade in place would work; that's the intent. But, things sometimes get broken. It's akin to a Windows update that breaks things; which has been happening too frequently these days.

I agree that starting from scratch again seems like a lot of unnecessary work.

What I'd suggest doing is backing up your SD card before making major changes. Use Win32DiskImager to make the image (assuming you're using a Windows computer), then do updates and/or upgrades. If something breaks, you can copy your image back to the SD card and you're back to your last working setup. This should be significantly less work because you wouldn't need to re-install packages, redo any edits you made (like hostname and putting other hosts in /etc/hosts), and restore your files.

pfletch101
Posts: 423
Joined: Sat Feb 24, 2018 4:09 am

Re: Can't Compile Any More! Please need help!

Sun May 26, 2019 6:58 pm

marcellatwin wrote:
Sun May 26, 2019 4:08 pm
pfletch101 wrote: Upgrading (in place) a system to Stretch is an iffy process. When I tried it, last year, I encountered all sorts of issues. The usual recommendation is to burn the latest version of Stretch to a new SD card and then reconfigure it to your taste. The time that this takes is (for most people) well worth it, in terms of the stability of the ultimate 'product'.
So just so I understand, cause I'm still fairly new to the Pi and mostly self-taught when it come to specifically the Pi so I miss things sometimes, but you mean to wipe clean the SD (reformat), burn a brand new copy of Stretch, then reinstall any programs/libraries and reconfigure everything to get it back to where you left off (vnc settings, ssh settings, etc.)?? Wow that does sound like a lot of work.
That is not quite what I said! In particular, I said: "...burn the latest version of Stretch to a new SD card...". That way, you have all the content of the old card at least potentially available for reference as you reconfigure the new system. But yes, I do recommend starting from a new clean system when you do a complete version upgrade. Some people have managed in place upgrades with few problems, but when there are problems, they don't necessarily appear immediately or in obvious ways. I would rather spend a finite amount of time 'retweaking' my new system to my taste than a potentially infinite amount of time dealing with confusing, potentially upgrade-related, problems if/when they crop up.

pfletch101
Posts: 423
Joined: Sat Feb 24, 2018 4:09 am

Re: Can't Compile Any More! Please need help!

Sun May 26, 2019 7:02 pm

Ernst wrote:
Sun May 26, 2019 4:28 pm

There is an even better way to upgrade:
- freeze the environment on your current system, that means no more updates
- buy a new raspberry and a new memory card
- install a new copy of stretch
- install and configure whatever you need
- transfer anything you need from the current system to the new system.
- shutdown your old system into sleep mode (meaning put it away without power) to be used for the buster upgrade (RSN)

It may sound a lot but I can guarantee that you will learn more this way.
Not everyone can afford to buy a new Pi in order to make their upgrade path easier! BTW, it has been said that Buster will support a reasonably seamless in place upgrade from Stretch, but I remain skeptical.

marcellatwin
Posts: 31
Joined: Sat Jan 27, 2018 6:41 pm
Location: USA

Re: Can't Compile Any More! Please need help!

Wed Jun 05, 2019 8:27 pm

dl324 wrote: Most of us are in the same situation. It's not like we're going to take a class to learn how to use RPi's. As with most things related to computers or programing, there's more than one way to accomplish a task.
That makes me feel a little better. I actually thought most people were more academically trained in Pi's or at least this type of SoC.
dl324 wrote: What I'd suggest doing is backing up your SD card before making major changes. Use Win32DiskImager to make the image (assuming you're using a Windows computer), then do updates and/or upgrades. If something breaks, you can copy your image back to the SD card and you're back to your last working setup. This should be significantly less work because you wouldn't need to re-install packages, redo any edits you made (like hostname and putting other hosts in /etc/hosts), and restore your files.
So I'm actually using Mac but I see what you're say and I think that's better. I just discovered how to use Etcher and like it, so I think I'll follow what you said, by creating my own "restore point" by copying the image of the current SD card before any major upgrades. I'll feel a lot better knowing I can go back when I try to upgrade to Buster or something.
pfletch101 wrote:
marcellatwin wrote:
Sun May 26, 2019 4:08 pm
pfletch101 wrote: Upgrading (in place) a system to Stretch is an iffy process. When I tried it, last year, I encountered all sorts of issues. The usual recommendation is to burn the latest version of Stretch to a new SD card and then reconfigure it to your taste. The time that this takes is (for most people) well worth it, in terms of the stability of the ultimate 'product'.
So just so I understand, cause I'm still fairly new to the Pi and mostly self-taught when it come to specifically the Pi so I miss things sometimes, but you mean to wipe clean the SD (reformat), burn a brand new copy of Stretch, then reinstall any programs/libraries and reconfigure everything to get it back to where you left off (vnc settings, ssh settings, etc.)?? Wow that does sound like a lot of work.
That is not quite what I said! In particular, I said: "...burn the latest version of Stretch to a new SD card...". That way, you have all the content of the old card at least potentially available for reference as you reconfigure the new system. But yes, I do recommend starting from a new clean system when you do a complete version upgrade. Some people have managed in place upgrades with few problems, but when there are problems, they don't necessarily appear immediately or in obvious ways. I would rather spend a finite amount of time 'retweaking' my new system to my taste than a potentially infinite amount of time dealing with confusing, potentially upgrade-related, problems if/when they crop up.
I'll keep that in mind, thanks. Sounds similar to what dl324 said in terms of always have a backup plan.

Thank you all for your help. I think I have a way forward for any future upgrades or issues.

plugwash
Forum Moderator
Forum Moderator
Posts: 3357
Joined: Wed Dec 28, 2011 11:45 pm

Re: Can't Compile Any More! Please need help!

Thu Jun 06, 2019 6:09 pm

marcellatwin wrote:
Sat May 25, 2019 3:09 am
So going off your advice I did the following:

Code: Select all

sudo apt purge binutils
sudo apt install binutils
Which seemed to get ride of gcc entirely, both versions. Could you tell me briefly what is binutils, or what it contains?
binutils contains the "GNU assembler, linker and binary utilities"

The gcc packages depend on binutils, so removing binutils will also cause them to be removed.
I then did:

Code: Select all

sudo apt autoremove
sudo apt install gcc
...
gcc version 6.3.0 20170516 (Raspbian 6.3.0-18+rpi1+deb9u1) 
GNU ld (GNU Binutils for Raspbian) 2.28
So I now have the same version as yours and it looks like it works!!!
Thank you so much. It was really driving me crazy.
So what exactly do you think happened?
My guess would be either the linker or one of the libraries it depends on (removed as part of your apt autoremove step) was corrupted. SD cards aren't the worlds most reliable storage media and an upgrade to a new major release means a major workout for the storage system.

Return to “Raspbian”