Skip to content

Instantly share code, notes, and snippets.

@yosoufe
Last active July 26, 2022 14:19
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save yosoufe/ad45f45c10fe08abecbf53000d0d199f to your computer and use it in GitHub Desktop.
Save yosoufe/ad45f45c10fe08abecbf53000d0d199f to your computer and use it in GitHub Desktop.
Compile and install gcc-9.3.0

Disclaimer:

I am documenting it here for my personal use, with the hope of being useful for others. You may use it with your own responsibility

helpful links

  1. http://www.linuxfromscratch.org/blfs/view/svn/general/gcc.html
  2. https://gcc.gnu.org/install/configure.html
  3. https://gcc.gnu.org/git.html
  4. https://gcc.gnu.org/wiki/InstallingGCC

Get Source Code

git clone git://gcc.gnu.org/git/gcc.git
cd gcc
git checkout releases/gcc-9.3.0

or download and extract it from here: https://ftp.gnu.org/gnu/gcc/gcc-9.3.0/

Compile and Install

# requirements
sudo apt-get install flex bison
mkdir build
./contrib/download_prerequisites --directory=build

cd    build
../configure                                           \
    --prefix=/usr                                      \
    --disable-multilib                                 \
    --with-system-zlib                                 \
    --enable-languages=c,c++,d,fortran,go,objc,obj-c++ \
    --program-suffix=-9.3.0

make -j$(nproc)
sudo make install -j$(nproc)
@MikeOpenHWGroup
Copy link

Hi @yosoufe, thanks for this is helped me a lot. Just a small issue. contrib/download_prerequisites wants to be run from the directory where contrib lives, so the commands are like this":

./contrib/download_prerequisites

mkdir build
cd    build

../configure  ...

@yosoufe
Copy link
Author

yosoufe commented Dec 4, 2020

Thanks @MikeOpenHWGroup, I retested and updated the gist.

@franzitobambino
Copy link

Thanks for this guys, used it to install VMware on Kali Linux

@franzitobambino
Copy link

@yosoufe VMware needs to know where the directory for 9.3.0 (gcc) is so it can be installed. Any idea which file to use and where it is in my new gcc folder i got from the git clone? Thanks in any case

@yosoufe
Copy link
Author

yosoufe commented Sep 10, 2021

@yosoufe VMware needs to know where the directory for 9.3.0 (gcc) is so it can be installed. Any idea which file to use and where it is in my new gcc folder i got from the git clone? Thanks in any case

@inthelightofthetruth I have not used Kali or VMware. Is it finding a wrong version of gcc? If so, that means you need to change the symbolic link of currently installed gcc.

$ which gcc
/usr/bin/gcc

$ ll /usr/bin/gcc
lrwxrwxrwx 1 root root 5 Mar 20  2020 /usr/bin/gcc -> gcc-9*

$ ll /usr/bin/g++
lrwxrwxrwx 1 root root 5 Mar 20  2020 /usr/bin/g++ -> g++-9*

If I want to change the default gcc version, I only change these symbolic links using ln to the GCC that I want.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment