Installing g++ 5 on Amazon Linux

I'm trying to install g++ 5.x on an EC2 instance running Amazon Linux; in Amazon's central repository the latest version is 4.8.3. What configuration to can I make to allow yum to find a newer gcc-c++ package?

console log


Solution 1:

Late to the party, but for those like me:

sudo yum install gcc72 gcc72-c++

Solution 2:

For Amazon Linux 2, you have to install the following

sudo yum install -y gcc-c++

It's a requirement to install some Ruby gems that need native extensions

Solution 3:

Installing gcc5:

# Install required libraries
sudo yum install libmpc-devel mpfr-devel gmp-devel

# Gather source code
export GCC_VERSION=5.5.0
cd /tmp
curl -o "gcc-${GCC_VERSION}.tar.gz" \
  https://ftp.gnu.org/gnu/gcc/gcc-${GCC_VERSION}/gcc-    ${GCC_VERSION}.tar.gz
tar xvzf "gcc-${GCC_VERSION}.tar.gz"
cd gcc-${GCC_VERSION}

# Configure and compile
./configure --with-system-zlib --disable-multilib --enable-languages=c,c++
make -j 8

# Install
sudo make install

Ensure /usr/local/bin/ is in your PATH

You may advantageously install version 7.3.0 released on 25th January 18 here