11

How can I install GCC 4.8 on Raspberry Pi? Do I need to compile it from source? Should I update from Raspbian wheezy to a newer version?

5

As long as your Raspberry Pi is up to date, then you can just download and patch GCC 4.8 to run on you Raspberry Pi.

  1. Download GCC sources

    $ wget ftp://ftp.fu-berlin.de/unix/languages/gcc/snapshots/LATEST-4.8/*.bz2
    
  2. Extract sources

    $ tar xf gcc-4.8-20120826.tar.bz2
    
  3. Patch sources

    We need to get and apply two debian specific patches for GCC:

    $ wget http://anonscm.debian.org/viewvc/gcccvs/branches/sid/gcc-4.7/debian/patches/armhf-triplet.diff?view=co -O armhf-triplet.diff
    $ wget http://anonscm.debian.org/viewvc/gcccvs/branches/sid/gcc-4.7/debian/patches/gcc-multiarch-trunk.diff?view=co -O gcc-multiarch-trunk.diff
    $ cd gcc-4.8-20120826
    $ patch -p2 -i ../armhf-triplet.diff
    $ patch -p2 -i ../gcc-multiarch-trunk.diff
    

    Note: There will be a failed patch in libgcc, don't worry about it, as it's already been applied to gcc-4.8.

  4. Recreate .autoconf files:

    $ cd gcc
    $ autoconf2.64
    $ cd ../libjava
    $ autoconf2.64
    $ cd ../
    
  5. Compile and install GCC: configure; make; make install

  • Not configure/make install anymore? – Thorbjørn Ravn Andersen Dec 17 '13 at 7:17
  • 1
    What does autoconf2.64 do? – HeatfanJohn Dec 18 '13 at 14:20
  • It appears that the gcc 4.8 snapshot you linked to (step 1) is no longer online. They only seem to keep the last 3 months or so of builds. wget ftp://ftp.fu-berlin.de/unix/languages/gcc/snapshots/LATEST-4.8/*.bz2 should do the trick to get their latest build of gcc 4.8. There's also a LATEST-4.9 and LATEST-4.10 folder as well. – Ponkadoodle Jul 2 '14 at 23:50
  • So after step 4, we still have to do the whole configure; make; make install commands? Because I'm not seeing any binaries, and gcc --version still reports 4.6. – Ponkadoodle Jul 3 '14 at 0:36
  • @Wallacoloo Yes, you do. I just walked through the process of patching GCC 4.8 so that it could compile properly. – syb0rg Jul 3 '14 at 0:39
8

In 2015-02-16-raspbian-wheezy is gcc-4.8 already as package (4.8.2), but not default. You can install it apt-get install gcc-4.8 g++-4.8 and then change the links in /usr/bin/

0

I tried the above -- ran into several issues. This might be easier (I'm trying it now):

http://www.raspberrypi.org/phpBB3/viewtopic.php?t=65516&p=481730

  • 3
    If you could post the gist of the directions here, that'd be great! It helps prevent link rot if anything ever changes on the linked site. – Fred Mar 30 '14 at 19:37
  • The downside to this solution is that it forces you to update you ENTIRE system to Debian Jessie. This may very well cause compatibility issues for some users (myself included). – Ponkadoodle Jul 3 '14 at 0:04
  • In keeping with our policy regarding informationless link-only answers, if this post is not edited to contain information that can stand as an answer, however minimal, in 48 hours it will be converted to Community Wiki to simplify having it corrected by the community. – Ghanima Aug 31 '17 at 19:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.