3

I'm using Amazon Linux on an EC2 instance started from the most recent 2017.03 AMI (ami-6df1e514).

This distribution comes with g++ 4.8.3 from 2013. I need something more recent that can compile C++14.

Is there any way to install a more recent gcc from some sort of binaries, or am I stuck compiling it from source?

I'm not seeing anything in the Amazon repos that looks recent:

[ec2-user@ip-... ~]$ yum list \*gcc\*
Loaded plugins: priorities, update-motd, upgrade-helper
Installed Packages
gcc.noarch                                                   4.8.3-3.20.amzn1                                      @amzn-main
gcc-c++.noarch                                               4.8.3-3.20.amzn1                                      @amzn-main
gcc-gfortran.noarch                                          4.8.3-3.20.amzn1                                      @amzn-main
gcc48.x86_64                                                 4.8.3-9.111.amzn1                                     @amzn-main
gcc48-c++.x86_64                                             4.8.3-9.111.amzn1                                     @amzn-main
gcc48-gfortran.x86_64                                        4.8.3-9.111.amzn1                                     @amzn-main
libgcc48.x86_64                                              4.8.3-9.111.amzn1                                     installed 
Available Packages
gcc-gnat.noarch                                              4.8.3-3.20.amzn1                                      amzn-main 
gcc44.x86_64                                                 4.4.6-4.81.amzn1                                      amzn-main 
gcc44-c++.x86_64                                             4.4.6-4.81.amzn1                                      amzn-main 
gcc44-gfortran.x86_64                                        4.4.6-4.81.amzn1                                      amzn-main 
gcc44-gnat.x86_64                                            4.4.6-4.81.amzn1                                      amzn-main 
gcc44-objc.x86_64                                            4.4.6-4.81.amzn1                                      amzn-main 
gcc44-objc++.x86_64                                          4.4.6-4.81.amzn1                                      amzn-main 
gcc48-gnat.x86_64                                            4.8.3-9.111.amzn1                                     amzn-main 
gcc48-plugin-devel.x86_64                                    4.8.3-9.111.amzn1                                     amzn-main 
libgcc44.i686                                                4.4.6-4.81.amzn1                                      amzn-main 
libgcc44.x86_64                                              4.4.6-4.81.amzn1                                      amzn-main 
libgcc48.i686                                                4.8.3-9.111.amzn1                                     amzn-main 

Is there an alternative, testing repo or something that contains more recent packages?

bcattle
  • 161
  • 2
  • 8
  • What's the issue? – bcattle Aug 14 '17 at 19:22
  • 1
    Many packages available for Amazon Linux are out of date. The best approach is to use Ubuntu. If you have to start with AL your options are to find a repository that's up to date (Centos) or build from source. – Tim Aug 14 '17 at 19:33

2 Answers2

2

Use the new Amazon Linux 2 at https://aws.amazon.com/amazon-linux-2/ which has gcc v7.2.1 in it's default repo.

0

Currently it looks like that:

# yum list \*gcc10\*
Loaded plugins: extras_suggestions, langpacks, priorities, update-motd
Installed Packages
gcc10.x86_64                                   10.3.1-1.amzn2.0.1                    @amzn2-core
gcc10-binutils.x86_64                          2.35-21.amzn2.0.1                     @amzn2-core
gcc10-binutils-gold.x86_64                     2.35-21.amzn2.0.1                     @amzn2-core
Available Packages
gcc10-binutils.i686                            2.35-21.amzn2.0.1                     amzn2-core 
gcc10-binutils-devel.x86_64                    2.35-21.amzn2.0.1                     amzn2-core 
gcc10-c++.x86_64                               10.3.1-1.amzn2.0.1                    amzn2-core 
gcc10-gdb-plugin.x86_64                        10.3.1-1.amzn2.0.1                    amzn2-core 
gcc10-plugin-devel.x86_64                      10.3.1-1.amzn2.0.1                    amzn2-core

Therefore just execute: yum install -y gcc10.x86_64 gcc10-c++.x86_64 and check it:

# gcc10-gcc --version
gcc10-gcc (GCC) 10.3.1 20210422 (Red Hat 10.3.1-1)
Copyright (C) 2020 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.```