Amazon-Ec2

我可以從 Amazon Linux 上的二進製文件安裝最新的 gcc 嗎?

  • October 11, 2021

我在從最新的 2017.03 AMI ( ami-6df1e514 ) 開始的 EC2 實例上使用 Amazon Linux。

此發行版附帶g++2013 年的 4.8.3。我需要可以編譯 C++14 的更新版本。

有什麼方法可以gcc從某種二進製文件中安裝更新的版本,還是我堅持從原始碼編譯它?

我在 Amazon 儲存庫中沒有看到任何看起來最近的東西:

[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 

是否有替代方案,測試回購或包含更新包的東西?

在https://aws.amazon.com/amazon-linux-2/使用新的 Amazon Linux 2,它的預設儲存庫中有 gcc v7.2.1。

目前它看起來像這樣:

# 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

因此只需執行: yum install -y gcc10.x86_64 gcc10-c++.x86_64並檢查它:

# 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.```

引用自:https://serverfault.com/questions/868600