主要參照如下兩篇文章html
https://www.cppfans.org/1719.htmlbash
https://blog.csdn.net/cybertan/article/details/8101883ui
1 tar -xvf gcc.tar.gz > /dev/null
在後面加上 > /dev/null以後,只有錯誤信息會輸出到屏幕上,用於檢查解壓縮的過程當中是否有錯誤。spa
1 ./contrib/download_prerequisites
1 mkdir build 2 cd build
1 ../configure --prefix=$HOME/.local/ --enable-checking=release --disable-multilib
1 make -j8 2 make install
注意事項:在開始編譯以前應該unset一些環境變量,參見.net
https://stackoverflow.com/questions/12255058/g-4-7-1-compilation-error-conflicting-types-for-strsignalcode
https://stackoverflow.com/questions/21685255/how-can-i-understand-these-dreadful-errors-when-building-gcc-4-8-2server
1 unset LIBRARY_PATH CPATH C_INCLUDE_PATH PKG_CONFIG_PATH CPLUS_INCLUDE_PATH INCLUDE