如何升級CentOS上的C++編譯器版本
最近,在CentOS上編譯一個程式發生編譯器錯誤,編譯器抱怨沒有這個選項"-std=c++11",Google了一下發現是編譯器的版本太舊了。你可以透過"gcc --version"得知你的編譯器環境版本。 # gcc --version gcc (GCC) 4.4.7 20120313 (Red Hat 4.4.7-16) Copyright (C) 2010 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO 步驟: 1. 安裝來源 wget http://people.centos.org/tru/devtools-2/devtools-2.repo -O /etc/yum.repos.d/devtools-2.repo 2. 套件管理資料庫更新 yum upgrade 3. 安裝編譯器相關套件 yum install devtoolset-2-gcc devtoolset-2-binutils devtoolset-2-gcc-c++ 4. 啟用編譯環境 scl enable devtoolset-2 bash 5. 確認編譯器版本是否已經更新 # gcc --version gcc (GCC) 4.8.2 20140120 (Red Hat 4.8.2-15) Copyright (C) 2013 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO 參考來源 C++11 on CentOS 6, https://edwards.sdsu.edu/research/c11-on-centos-6/