Centos 6裡的GCC是4.4.7,而現在最新的版本是5,由於有些用戶的電腦都在用最新的,所以必須升級.如果要升級的話的確是比較麻煩,分分鐘會導致系統不穩定,當然肯定有辦法升級的,只是要花一點時間自己上網找,我第一次弄的時候也花了好幾天,走了許多冤枉路,後來還好找到這個網站,一步步的教導怎樣升級才把我的問題解決.
我直接用root帳戶來升級.
1. 確保gcc,gcc++已經安裝了
#yum install gcc gcc-c++
2. 然後檢查版本
#gcc --version
gcc (GCC) 4.4.7 20120313 (Red Hat 4.4.7-16) - 按個人的伺服器而定
#g++ --version
g++ (GCC) 4.4.7 20120313 (Red Hat 4.4.7-16) - 按個人的伺服器而定
#which gcc
/usr/bin/gcc
#which g++
/usr/bin/g++
3. 接著把相關的dependencies安裝
#yum install svn texinfo-tex flex zip libgcc.i686 glibc-devel.i686 (不然會面對一些問題)
4. 檢查gcc的新版本
#svn ls svn://gcc.gnu.org/svn/gcc/tags | grep gcc | grep release
gcc-2_95-release/
...
gcc_4_9_2_release/
gcc-4_9_3_release/
gcc-5_1_0_release/
gcc_5_2_0_release/
5.開一個新的directory,用svn check out把source它下載
#mkdir ~/sourceInstallations
#cd ~/sourceInstallations
#svn co svn://gcc.gnu.org/svn/gcc/tags/gcc_4_9_3_release/
6.下載prerequisites
#cd gcc_4_9_3_release/
#./contrib/download_prerequisites
7.升級新版本
#cd ..
#mkdir gcc_4_9_3_release_build/
#cd gcc_4_9_3_release_build/
#../gcc_4_9_3_release/configure && make && sudo make install && echo "success"
8.安裝完畢後,檢查新版本
#hash -r
#gcc --version
gcc (GCC) 4.9.3
#g++ --version
g++ (GCC) 4.9.3
#which gcc
/usr/local/bin/gcc
#which g++
/usr/local/bin/g++
9.再來最後一步
#echo "/usr/local/lib64" > usrLocalLib64.conf
#mv usrLocalLib64.conf /etc/ld.so.conf.d/
#ldconfig (這裡會出現這個"xxx is not an ELF file - it has the wrong magic bytes at the start.",可以不理他)
10.最後把sourceInstallations的directory丟掉
#cd ~/
#rm -rf sourceInstallations
相關網站:
https://www.vultr.com/docs/how-to-install-gcc-on-centos-6
How Docker can help you run apps on your Mac
-
Docker is an important tool for developers and for running apps across
networks, and it has many uses for the pro and hobbyist alike. Here's how
you can ge...
33 分鐘前
















