曲折的gcc升級詳細步驟
由於要安裝一高可用軟體,其在編譯安裝的時候提示需要4.4+版本以上的gcc,而我的系統是rhel5.8,gcc版本是gcc version 4.1.2,因此需要將gcc版本升級,看似簡單的升級,實施起來還是頗為曲折,僅將個人安裝過程記錄下來,希望對有需要的人有所幫助。
gcc的升級有多種方式可以完成,最簡單的方式就是透過線上yum源的方式完成升級,其次是透過本地yum源做升級,還有可以透過rpm包升級以及原始碼包升級的方式。由於我這內網機,而且受限於系統版本和依賴包,透過本地yum和rpm也不是特別現實(比較繁瑣),所以首選的方案是透過原始碼包升級。具體升級步驟如下:
1、下載升級包所需軟體
2、依次安裝相關的軟體
1)boost安裝(可不裝)
tar -xzvf boost_1_60_0.tar.gz
cd boost_1_60_0
./bootstrap.sh
./b2
./bjam install
2)gmp安裝
tar -xzv gmp-5.1.3.tar.gz
cd gmp-5.1.3
./configure --prefix=/usr/local/gmp
make
make install
3)mpfr安裝
tar -xzvf mpfr-3.1.3.tar.gz
cd mpfr-3.1.3
./configure --with-gmp-include=/usr/local/gmp/include --with-gmp-lib=/usr/local/gmp/lib --prefix=/usr/local/mpfr
make
make install
4)mpc安裝
tar -xzvf mpc-1.0.3.tar.gz
cd mpc-1.0.3
./configure --with-mpfr-include=/usr/local/mpfr/include --with-mpfr-lib=/usr/local/mpfr/lib --with-gmp-include=/usr/local/gmp/include --with-gmp-lib=/usr/local/gmp/lib --prefix=/usr/local/mpc
make
make install
5)isl安裝
tar -xzvf isl-0.11.1.tar.gz
cd isl-0.11.1
./configure --with-gmp-prefix==/usr/local/gmp --prefix=/usr/local/isl
make
make install
6)cloog安裝
tar -xzvf cloog-0.18.1.tar.gz
cd cloog-0.18.1
./configure --with-gmp-prefix==/usr/local/gmp -with-isl-prefix=/usr/local/isl --prefix=/usr/local/cloog
make
make install
7)gcc安裝
tar -xzvf gcc-4.8.0.tar.gz
cd gcc-4.8.0
vi /etc/ld.so.conf
/usr/local/isl/lib
/usr/local/cloog/lib
/usr/local/mpc/lib
/usr/local/mpfr/lib
/usr/local/gmp/lib
ldconfig
./configure --with-mpfr=/usr/local/mpfr --with-gmp=/usr/local/gmp --with-mpc=/usr/local/mpc --with-mpfr-include=/usr/local/mpfr/include --with-mpfr-lib=/usr/local/mpfr/lib --with-gmp-lib=/usr/local/gmp/lib --with-gmp-include=/usr/local/gmp/include --with-mpc-lib=/usr/local/mpc/lib --with-mpc-inclue=/usr/local/mpc/include --with-isl-include=/usr/local/isl/include --with-isl-lib=/usr/local/isl/lib/ --with-cloog-include=/usr/local/cloog/include --with-cloog-lib=/usr/local/cloog/lib --enable-languages=c,c++ --enable-threads=posix --disable-multilib
make
make install
3、安裝後校驗
# gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/local/libexec/gcc/x86_64-unknown-linux-gnu/4.8.0/lto-wrapper
Target: x86_64-unknown-linux-gnu
Configured with: ./configure --with-mpfr=/usr/local/mpfr --with-gmp=/usr/local/gmp --with-mpc=/usr/local/mpc --with-isl-include=/usr/local/isl/include --with-isl-lib=/usr/local/isl/lib/ --with-cloog=/usr/local/cloog --enable-languages=c,c++ --enable-threads=posix --disable-multilib --disable-bootstrap --disable-libstdcxx-pch
Thread model: posix
gcc version 4.8.0 (GCC)
4、安裝過程錯誤資訊以及解決方案
1)解壓gcc安裝包直接編譯
錯誤資訊:
configure: error: Building GCC requires GMP 4.2+, MPFR 2.4.0+ and MPC 0.8.0+.Try the --with-gmp, --with-mpfr and/or --with-mpc options to specify their locatio
錯誤原因:
對gcc原始碼編譯安裝,需要GMP 4.2+,MPFR 2.4.0+ and MPC 0.8.0+的事先安裝,如果檢測不到預設標頭檔案和庫檔案裡存在上述安裝包檔案,則會報錯。
解決方案:
透過安裝gmp,mpfr,mpc安裝包,並指定其庫檔案路徑進行編譯gcc即可,具體版本和安裝步驟詳細參考上述安裝步驟。
安裝gmp,mpfr,mpc後執行下面編譯指令碼進行編譯
./configure --with-mpfr=/usr/local/mpfr --with-gmp=/usr/local/gmp --with-mpc=/usr/local/mpc --with-mpfr-include=/usr/local/mpfr/include --with-mpfr-lib=/usr/local/mpfr/lib --with-gmp-lib=/usr/local/gmp/lib --with-gmp-include=/usr/local/gmp/include --with-mpc-lib=/usr/local/mpc/lib --with-mpc-inclue=/usr/local/mpc/include --enable-languages=c,c++ --enable-threads=posix --disable-multilib
2)編譯mpc安裝包出錯
錯誤資訊:
/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../lib64/libmpfr.a: could not read symbols: Bad value
collect2: ld returned 1 exit status
make[2]: *** [libmpc.la] Error 1
make[2]: Leaving directory `/tools/PXC/gcc/mpc-1.0.3/src'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/tools/PXC/gcc/mpc-1.0.3'
make: *** [all] Error 2
錯誤原因:
編譯mpc原始碼時,沒有指定gmp、mpfr對應的安裝路徑(主要是庫檔案和標頭檔案路徑)
解決方案:
在編譯指令碼里加入相應的gmp、mpfr安裝路徑或者庫檔案+標頭檔案路徑
./configure --with-mpfr-include=/usr/local/mpfr/include --with-mpfr-lib=/usr/local/mpfr/lib --with-gmp-include=/usr/local/gmp/include --with-gmp-lib=/usr/local/gmp/lib --prefix=/usr/local/mpc
或者
./configure --with-mpfr=/usr/local/mpfr --with-gmp=/usr/local/gmp --prefix=/usr/local/mpc
3)帶gmp、mpfr、mpc編譯引數,編譯gcc原始碼出錯
錯誤資訊:
conftest.c:10:25: error: isl/version.h: No such file or directory
錯誤原因:
沒安裝isl安裝包
解決方案:
安裝isl-0.11.1.tar.gz,具體安裝步驟參照上面內容。
4)原始碼編譯isl出錯
錯誤資訊:
./.libs/libisl.so: undefined reference to `__gmp_get_memory_functions'
collect2: ld returned 1 exit status
make[2]: *** [isl_cat] Error 1
./.libs/libisl.so: undefined reference to `__gmp_get_memory_functions'
collect2: ld returned 1 exit status
make[2]: *** [isl_polyhedron_detect_equalities] Error 1
make[2]: Leaving directory `/tools/PXC/gcc/isl-0.12.2'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/tools/PXC/gcc/isl-0.12.2'
make: *** [all] Error 2
錯誤原因:
isl編譯安裝,需要在指定gmp的安裝路徑
解決方案:
在編譯引數裡指定gmp的安裝路徑,並且格式為--with-gmp-prefix==,不能用--with-gmp
./configure --with-gmp-prefix=/usr/local/gmp --prefix=/usr/local/isl
參考檔案:!msg/isl-development/ejZLCmty4Nc/PrKXb9noTCoJ
5)安裝完gmp,mpfr,mpc,isl後,原始碼編譯gcc出錯
錯誤資訊:
configure:6098: gcc -c -g -O2 -DCLOOG_INT_GMP -I/usr/local/isl/include -I/usr/local/gmp/include -I/usr/local/mpfr/include -I/usr/local/mpc/include conftest.c >&5
conftest.c:10:27: error: cloog/version.h: No such file or directory
conftest.c: In function 'main':
conftest.c:15: error: 'choke' undeclared (first use in this function)
conftest.c:15: error: (Each undeclared identifier is reported only once
conftest.c:15: error: for each function it appears in.)
conftest.c:15: error: expected ';' before 'me'
錯誤原因:
缺少安裝包cloog,沒找到相應的庫檔案。
解決方案:
安裝cloog-0.18.1.tar.gz ,具體安裝步驟參照上面安裝步驟,安裝cloog後,繼續編譯gcc
./configure --with-mpfr=/usr/local/mpfr --with-gmp=/usr/local/gmp --with-mpc=/usr/local/mpc --with-mpfr-include=/usr/local/mpfr/include --with-mpfr-lib=/usr/local/mpfr/lib --with-gmp-lib=/usr/local/gmp/lib --with-gmp-include=/usr/local/gmp/include --with-mpc-lib=/usr/local/mpc/lib --with-mpc-inclue=/usr/local/mpc/include --with-isl-include=/usr/local/isl/include --with-isl-lib=/usr/local/isl/lib/ --with-cloog-include=/usr/local/cloog/include --with-cloog-lib=/usr/local/cloog/lib --enable-languages=c,c++ --enable-threads=posix --disable-multilib --disable-bootstrap --disable-libstdcxx-pch
6)安裝cloog遇到下屬錯誤
錯誤資訊:
./conftest: error while loading shared libraries: libisl.so.10: cannot open shared object file: No such file or directory
錯誤原因:
找不到isl的庫檔案,需要在/etc/ld.so.conf中新增以下內容/usr/local/isl/lib,並透過ldconfig使其生效。
解決方案:
透過LD_LIBRARY_PATH指定isl庫檔案路徑或者在/etc/ld.so.conf中新增以下內容/usr/local/isl/lib,並透過ldconfig使其生效。然後透過相應的編輯引數指定isl的庫檔案和標頭檔案,進行cloog編譯安裝。透過strings /etc/ld.so.cache | grep libisl 檢視是否已經將庫檔案寫入快取。
7)下屬錯誤可以忽略
錯誤資訊01:
conftest.cpp:11:2: error: #error -static-libstdc++ not implemented
5、參考文件:
!msg/isl-development/ejZLCmty4Nc/PrKXb9noTCoJ
gcc的升級有多種方式可以完成,最簡單的方式就是透過線上yum源的方式完成升級,其次是透過本地yum源做升級,還有可以透過rpm包升級以及原始碼包升級的方式。由於我這內網機,而且受限於系統版本和依賴包,透過本地yum和rpm也不是特別現實(比較繁瑣),所以首選的方案是透過原始碼包升級。具體升級步驟如下:
1、下載升級包所需軟體
boost_1_60_0.tar.gz
gcc-4.8.0.tar.gz 必須
isl-0.11.1.tar.gz 必須
mpc-1.0.3.tar.gz 必須
cloog-0.18.1.tar.gz ftp://gcc.gnu.org/pub/gcc/infrastructure/ 必須
gmp-5.1.3.tar.gz 必須
libelf-0.8.13.tar.gz
mpfr-3.1.3.tar.gz 必須
gcc-4.8.0.tar.gz 必須
isl-0.11.1.tar.gz 必須
mpc-1.0.3.tar.gz 必須
cloog-0.18.1.tar.gz ftp://gcc.gnu.org/pub/gcc/infrastructure/ 必須
gmp-5.1.3.tar.gz 必須
libelf-0.8.13.tar.gz
mpfr-3.1.3.tar.gz 必須
2、依次安裝相關的軟體
1)boost安裝(可不裝)
tar -xzvf boost_1_60_0.tar.gz
cd boost_1_60_0
./bootstrap.sh
./b2
./bjam install
2)gmp安裝
tar -xzv gmp-5.1.3.tar.gz
cd gmp-5.1.3
./configure --prefix=/usr/local/gmp
make
make install
3)mpfr安裝
tar -xzvf mpfr-3.1.3.tar.gz
cd mpfr-3.1.3
./configure --with-gmp-include=/usr/local/gmp/include --with-gmp-lib=/usr/local/gmp/lib --prefix=/usr/local/mpfr
make
make install
4)mpc安裝
tar -xzvf mpc-1.0.3.tar.gz
cd mpc-1.0.3
./configure --with-mpfr-include=/usr/local/mpfr/include --with-mpfr-lib=/usr/local/mpfr/lib --with-gmp-include=/usr/local/gmp/include --with-gmp-lib=/usr/local/gmp/lib --prefix=/usr/local/mpc
make
make install
5)isl安裝
tar -xzvf isl-0.11.1.tar.gz
cd isl-0.11.1
./configure --with-gmp-prefix==/usr/local/gmp --prefix=/usr/local/isl
make
make install
6)cloog安裝
tar -xzvf cloog-0.18.1.tar.gz
cd cloog-0.18.1
./configure --with-gmp-prefix==/usr/local/gmp -with-isl-prefix=/usr/local/isl --prefix=/usr/local/cloog
make
make install
7)gcc安裝
tar -xzvf gcc-4.8.0.tar.gz
cd gcc-4.8.0
vi /etc/ld.so.conf
/usr/local/isl/lib
/usr/local/cloog/lib
/usr/local/mpc/lib
/usr/local/mpfr/lib
/usr/local/gmp/lib
ldconfig
./configure --with-mpfr=/usr/local/mpfr --with-gmp=/usr/local/gmp --with-mpc=/usr/local/mpc --with-mpfr-include=/usr/local/mpfr/include --with-mpfr-lib=/usr/local/mpfr/lib --with-gmp-lib=/usr/local/gmp/lib --with-gmp-include=/usr/local/gmp/include --with-mpc-lib=/usr/local/mpc/lib --with-mpc-inclue=/usr/local/mpc/include --with-isl-include=/usr/local/isl/include --with-isl-lib=/usr/local/isl/lib/ --with-cloog-include=/usr/local/cloog/include --with-cloog-lib=/usr/local/cloog/lib --enable-languages=c,c++ --enable-threads=posix --disable-multilib
make
make install
3、安裝後校驗
# gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/local/libexec/gcc/x86_64-unknown-linux-gnu/4.8.0/lto-wrapper
Target: x86_64-unknown-linux-gnu
Configured with: ./configure --with-mpfr=/usr/local/mpfr --with-gmp=/usr/local/gmp --with-mpc=/usr/local/mpc --with-isl-include=/usr/local/isl/include --with-isl-lib=/usr/local/isl/lib/ --with-cloog=/usr/local/cloog --enable-languages=c,c++ --enable-threads=posix --disable-multilib --disable-bootstrap --disable-libstdcxx-pch
Thread model: posix
gcc version 4.8.0 (GCC)
4、安裝過程錯誤資訊以及解決方案
1)解壓gcc安裝包直接編譯
錯誤資訊:
configure: error: Building GCC requires GMP 4.2+, MPFR 2.4.0+ and MPC 0.8.0+.Try the --with-gmp, --with-mpfr and/or --with-mpc options to specify their locatio
錯誤原因:
對gcc原始碼編譯安裝,需要GMP 4.2+,MPFR 2.4.0+ and MPC 0.8.0+的事先安裝,如果檢測不到預設標頭檔案和庫檔案裡存在上述安裝包檔案,則會報錯。
解決方案:
透過安裝gmp,mpfr,mpc安裝包,並指定其庫檔案路徑進行編譯gcc即可,具體版本和安裝步驟詳細參考上述安裝步驟。
安裝gmp,mpfr,mpc後執行下面編譯指令碼進行編譯
./configure --with-mpfr=/usr/local/mpfr --with-gmp=/usr/local/gmp --with-mpc=/usr/local/mpc --with-mpfr-include=/usr/local/mpfr/include --with-mpfr-lib=/usr/local/mpfr/lib --with-gmp-lib=/usr/local/gmp/lib --with-gmp-include=/usr/local/gmp/include --with-mpc-lib=/usr/local/mpc/lib --with-mpc-inclue=/usr/local/mpc/include --enable-languages=c,c++ --enable-threads=posix --disable-multilib
2)編譯mpc安裝包出錯
錯誤資訊:
/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../lib64/libmpfr.a: could not read symbols: Bad value
collect2: ld returned 1 exit status
make[2]: *** [libmpc.la] Error 1
make[2]: Leaving directory `/tools/PXC/gcc/mpc-1.0.3/src'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/tools/PXC/gcc/mpc-1.0.3'
make: *** [all] Error 2
錯誤原因:
編譯mpc原始碼時,沒有指定gmp、mpfr對應的安裝路徑(主要是庫檔案和標頭檔案路徑)
解決方案:
在編譯指令碼里加入相應的gmp、mpfr安裝路徑或者庫檔案+標頭檔案路徑
./configure --with-mpfr-include=/usr/local/mpfr/include --with-mpfr-lib=/usr/local/mpfr/lib --with-gmp-include=/usr/local/gmp/include --with-gmp-lib=/usr/local/gmp/lib --prefix=/usr/local/mpc
或者
./configure --with-mpfr=/usr/local/mpfr --with-gmp=/usr/local/gmp --prefix=/usr/local/mpc
3)帶gmp、mpfr、mpc編譯引數,編譯gcc原始碼出錯
錯誤資訊:
conftest.c:10:25: error: isl/version.h: No such file or directory
錯誤原因:
沒安裝isl安裝包
解決方案:
安裝isl-0.11.1.tar.gz,具體安裝步驟參照上面內容。
4)原始碼編譯isl出錯
錯誤資訊:
./.libs/libisl.so: undefined reference to `__gmp_get_memory_functions'
collect2: ld returned 1 exit status
make[2]: *** [isl_cat] Error 1
./.libs/libisl.so: undefined reference to `__gmp_get_memory_functions'
collect2: ld returned 1 exit status
make[2]: *** [isl_polyhedron_detect_equalities] Error 1
make[2]: Leaving directory `/tools/PXC/gcc/isl-0.12.2'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/tools/PXC/gcc/isl-0.12.2'
make: *** [all] Error 2
錯誤原因:
isl編譯安裝,需要在指定gmp的安裝路徑
解決方案:
在編譯引數裡指定gmp的安裝路徑,並且格式為--with-gmp-prefix==,不能用--with-gmp
./configure --with-gmp-prefix=/usr/local/gmp --prefix=/usr/local/isl
參考檔案:!msg/isl-development/ejZLCmty4Nc/PrKXb9noTCoJ
5)安裝完gmp,mpfr,mpc,isl後,原始碼編譯gcc出錯
錯誤資訊:
configure:6098: gcc -c -g -O2 -DCLOOG_INT_GMP -I/usr/local/isl/include -I/usr/local/gmp/include -I/usr/local/mpfr/include -I/usr/local/mpc/include conftest.c >&5
conftest.c:10:27: error: cloog/version.h: No such file or directory
conftest.c: In function 'main':
conftest.c:15: error: 'choke' undeclared (first use in this function)
conftest.c:15: error: (Each undeclared identifier is reported only once
conftest.c:15: error: for each function it appears in.)
conftest.c:15: error: expected ';' before 'me'
錯誤原因:
缺少安裝包cloog,沒找到相應的庫檔案。
解決方案:
安裝cloog-0.18.1.tar.gz ,具體安裝步驟參照上面安裝步驟,安裝cloog後,繼續編譯gcc
./configure --with-mpfr=/usr/local/mpfr --with-gmp=/usr/local/gmp --with-mpc=/usr/local/mpc --with-mpfr-include=/usr/local/mpfr/include --with-mpfr-lib=/usr/local/mpfr/lib --with-gmp-lib=/usr/local/gmp/lib --with-gmp-include=/usr/local/gmp/include --with-mpc-lib=/usr/local/mpc/lib --with-mpc-inclue=/usr/local/mpc/include --with-isl-include=/usr/local/isl/include --with-isl-lib=/usr/local/isl/lib/ --with-cloog-include=/usr/local/cloog/include --with-cloog-lib=/usr/local/cloog/lib --enable-languages=c,c++ --enable-threads=posix --disable-multilib --disable-bootstrap --disable-libstdcxx-pch
6)安裝cloog遇到下屬錯誤
錯誤資訊:
./conftest: error while loading shared libraries: libisl.so.10: cannot open shared object file: No such file or directory
錯誤原因:
找不到isl的庫檔案,需要在/etc/ld.so.conf中新增以下內容/usr/local/isl/lib,並透過ldconfig使其生效。
解決方案:
透過LD_LIBRARY_PATH指定isl庫檔案路徑或者在/etc/ld.so.conf中新增以下內容/usr/local/isl/lib,並透過ldconfig使其生效。然後透過相應的編輯引數指定isl的庫檔案和標頭檔案,進行cloog編譯安裝。透過strings /etc/ld.so.cache | grep libisl 檢視是否已經將庫檔案寫入快取。
7)下屬錯誤可以忽略
錯誤資訊01:
conftest.cpp:11:2: error: #error -static-libstdc++ not implemented
5、參考文件:
!msg/isl-development/ejZLCmty4Nc/PrKXb9noTCoJ
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/27067062/viewspace-2123580/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- MySQL 升級詳細步驟 (包括 Percona)MySql
- ORACLE資料庫升級詳細步驟Oracle資料庫
- Oracle 11g升級PSU詳細步驟Oracle
- Oracle從10g升級到11g詳細步驟Oracle
- oracle升級步驟Oracle
- Oracle從10g升級到11g詳細操作步驟Oracle
- SAP 補丁升級步驟詳解 (轉)
- linux 核心升級步驟,kernel升級Linux
- windows10怎樣升級到10586_windows10電腦升級到10586詳細步驟Windows
- LVM建立的詳細步驟LVM
- MySQL的安裝步驟(詳細)MySql
- A*演算法(超級詳細講解,附有舉例的詳細手寫步驟)演算法
- Linux - 升級核心的操作步驟Linux
- 配置PLSQL Developer詳細步驟SQLDeveloper
- Oracle Stream配置詳細步驟Oracle
- IOS之GCD詳細步驟iOSGC
- gcc版本升級GC
- MyBatis的逆向工程詳細步驟操作MyBatis
- mysql 5.5.42升級到5.6.24步驟MySql
- GoldenGate軟體升級步驟Go
- dp安裝包升級步驟
- CATIA許可證升級步驟
- MySQL 5.6.27升級MySQL 5.7.18版本的升級步驟介紹MySql
- docker安裝portainer詳細步驟DockerAI
- mysql建立master/slave詳細步驟MySqlAST
- Github配置ssh key詳細步驟Github
- 12.1.0.2 單機 升級 19.16 RAC步驟詳解
- win10家庭版怎麼升級win10專業版詳細操作步驟Win10
- Linux安裝jdk的詳細步驟。LinuxJDK
- Linux安裝jdk的詳細步驟LinuxJDK
- CentOS GCC 升級 6.0CentOSGC
- Linux升級GCCLinuxGC
- CentOS 7 安裝MongoDB詳細步驟CentOSMongoDB
- 安裝fbprophet模組詳細步驟
- Linux安裝JDK詳細步驟LinuxJDK
- NFS伺服器搭建詳細步驟NFS伺服器
- 特別詳細的react專案搭建步驟React
- UBUNTU手動安裝JDK的詳細步驟UbuntuJDK