安装gcc 4.8.2 for cxx 11
1? ftp://gd.tuwien.ac.at/gnu/gcc/releases/gcc-4.8.2/ 下載解壓,configure報(bào)錯(cuò), 報(bào)錯(cuò):
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 locations.2 下載/安裝三個(gè)庫(kù); 或者查看? ./contrib/download_prerequisites.sh
tar -xvf gmp-5.0.5.tar.bz2
cd gmp-5.0.5
./configure && make && make check && make install;??? 頭文件在/usr/local/inclue/下, 庫(kù)在/usr/local/lib/下
wget http://www.mpfr.org/mpfr-current/mpfr-3.1.2.tar.bz2
tar xvf mpfr-3.1.2.tar.bz2
cd mpfr-3.1.2
./configure --with-gmp-include=/usr/local/include --with-gmp-lib=/usr/local/lib? && make && make install
tar xvf mpc-1.0.tar.gz
cd mpc-1.0
./configure --with-gmp-include=/usr/local/include --with-gmp-lib=/usr/loca/lib --with-mpfr-include=/usr/local/include --with-mpfr-lib=/usr/local/lib
make && make install
/sbin/ldconfig
3 安裝gcc?? https://gcc.gnu.org/install/
./configure --prefix=/usr/local/gcc-4.8.2 --enable-threads=posix --disable-checking --disable-multilib --enable-languages=c,c++ --with-gmp=/usr/local --with-mpfr=/usr/local --with-mpc=/usr/local
make;報(bào)錯(cuò)
centos 5.4 cc1plus: error: unrecognized command line option "-Wno-overlength-strings" g++ (GCC) 4.1.2 20080704 (Red Hat 4.1.2-48) man g++沒發(fā)現(xiàn)有這個(gè)選項(xiàng)。 g++版本低 腫么辦? 好像是4.3加入的這個(gè)選項(xiàng)。 得先升到4.3,再升到4.8 ?. 直接去掉這個(gè)選項(xiàng)試試(安裝成功、程序運(yùn)行也沒多大問題。該選項(xiàng)是和超長(zhǎng)字符串有關(guān)509)。centos 6.4 64位 g++ (GCC) 4.4.7 20120313 (Red Hat 4.4.7-4) 沒這問題configure: error: cannot compute suffix of object files: cannot compile。 將依賴庫(kù)路徑加到搜索路徑下, /sbin/ldconfig
make && make install
然后查看gcc/g++, 讓其指向新裝版本的gcc/g++
有些機(jī)器上回報(bào)錯(cuò) /usr/lib64/libstdc++.so.6: version `GLIBCXX_3.4.14'
strings /usr/lib64/libstdc++.so.6 | grep GLIBC 可以發(fā)現(xiàn)無(wú)3.4.14;
同理將 /usr/lib64/libstdc++.so.6 指向新裝的gcc下的libstdc++.so.6!!!直接指向最新的libstdc++.so.6.0.18, 否則有可能運(yùn)行時(shí)會(huì)報(bào)錯(cuò)GLIBCXX 版本問題
4 安裝新版本gdb
安裝gdb有可能報(bào)錯(cuò)缺少 termcap library
yum -y install ncurses.x86_64
yum -y install ncurses-devel.x86_64
用gdb調(diào)試時(shí),會(huì)報(bào)錯(cuò) Dwarf Error: wrong version in compilation unit header (is 4, should be 2)
從網(wǎng)上搜到的改 gcc選項(xiàng)無(wú)錫哦啊, 看到的棧幀和源代碼。
因此安裝新版本gdb即可。
wget http://ftp.gnu.org/gnu/gdb/gdb-7.8.tar.gz
解壓
./configure && make && make install
以下是別人筆記
我的環(huán)境:CentOS 6.2, kernel 3.1.10 ?x86_64
需要的配置:Disk space >= 6GB, Mem >= 1GB
從gcc.gnu.org下載gcc-4.8.2.tar.bz2,創(chuàng)建/root/buid-gcc目錄,以后所有編譯都在這個(gè)目錄里進(jìn)行了。
到ftp://gcc.gnu.org/pub/gcc/infrastructure/處下載以下輔助安裝包:gmp-4.3.2.tar.bz2,?mpfr-2.4.2.tar.bz2,?mpc-0.8.1.tar.gz
將以上bz2和gz ball全部放到/root/build-gcc目錄下。
1. 編譯gmp-4.3.2
展開gmp-4.3.2.tar.bz2:
#tar xf gmp-4.3.2.tar.bz2
#mkdir gmp-build
#cd gmp-build
#../gmp-4.3.2/configure --prefix=/root/rpmbuild/gmp-build?--build=x86_64-linux
注意:--build=x86_64-linux選項(xiàng)對(duì)于x86_64的平臺(tái)(比如我用的這個(gè)系統(tǒng))非常重要,否則,無(wú)法生成Makefile。
生成Makefile以后,用以下命令編譯:
#make
#make check
#make install
這樣就把gmp安裝到了/root/build-gcc/gmp-build目錄,gmp的安裝就完成了,/root/build-gcc/gmp-build目錄在將來(lái)安裝其他包的時(shí)候會(huì)作為參數(shù)被傳遞。
2. 編譯mpfr
#tar xf?mpfr-2.4.2.tar.bz2
#mkdir mpfr-build
#cd mpfr-build
#../mpfr-2.4.2/configure --prefix=/root/build-gcc/mpfr-build/ --with-gmp=/root/build-gcc/gmp-build
#make
#make check
#make install
3.編譯mpc
#tar xf mpc-0.8.1.tar.gz
#mkdir mpc-build
#cd mpc-build
#../mpc-0.8.1/configure --prefix=/root/build-gcc/mpc-build/ --with-gmp=/root/build-gcc/gmp-build/ --with-mpfr=/root/build-gcc/mpfr-build/
#make; make check; make install
4.編譯GCC
#tar xf gcc-4.7.2.tar.bz2
#mkdir gcc-build
設(shè)置LD_LIBRARY_PATH (可選)
#export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/root/build-gcc/mpc-build/lib:/root/build-gcc/mpfr-build/lib:/root/build-gcc/gmp-build/lib
創(chuàng)建makefile
#../gcc-4.7.2/configure --prefix=/root/build-gcc/gcc-build/ --enable-threads=posix --disable-checking --disable-multilib --enable-languages=c,c++ --with-gmp=/root/build-gcc/gmp-build/ --with-mpfr=/root/build-gcc/mpfr-build/ --with-mpc=/root/build-gcc/mpc-build/
Build過程中可能出現(xiàn)的錯(cuò)誤:
有些包沒裝(雖然之前已經(jīng)通過命令#yum groupinstall "Development Tools" 安裝了"Development Tools"),比如ppl和ppl-devel,可能會(huì)出現(xiàn)錯(cuò)誤:configure: error: cannot compute suffix of object files: cannot compile。查看日志發(fā)現(xiàn)錯(cuò)誤記錄: conftest.c:10:19: error: ppl_c.h: No such file or directory conftest.c:16: error: 'choke' undeclared (first use in this function) conftest.c:16: error: (Each undeclared identifier is reported only once conftest.c:16: error: for each function it appears in.) conftest.c:16: error: expected ';' before 'me' 這些錯(cuò)誤可以通過命令:
#yum install ppl ppl-devel
安裝這兩個(gè)包來(lái)改正。
另外,如果嚴(yán)謹(jǐn)一點(diǎn), make完后應(yīng)該要做make -k check的,但是make -k check會(huì)報(bào)告缺少autogen這個(gè)命令,可問題在于CentOS里很難找到這個(gè)autogen,所以,馬虎點(diǎn)好了,make完后直接make install。
make install完成后,將會(huì)在/root/build-gcc/gcc-build/bin目錄下生成最終的可執(zhí)行文件,如gcc,g++這些。而這時(shí),/root/build-gcc/gcc-build/bin并不存在于PATH中。這就需要將新生成的gcc放到/usr/bin中,讓其“可用”了:
#ln -s /root/build-gcc/gcc-build/bin/gcc /usr/bin/gcc-4.7
#ln -s /root/build-gcc/gcc-build/bin/g++ /usr/bin/g++-4.7
注意:以上必須用絕對(duì)路徑!
其后就可以用gcc-4.7和g++-4.7命令編程序了? http://blog.csdn.net/foreverdengwei/article/details/8691181
參考的資料:?http://blog.csdn.net/sstower/article/details/5624010
http://guliqun1983.blog.163.com/blog/static/50111685201162821716214/
http://www.cnblogs.com/chuncn/archive/2010/10/15/1851853.html
原文:http://chenjiajie.org/post/2012-11-25/40042373551
以下是別人的筆記。。。
以下來(lái)源于網(wǎng)絡(luò)。
from http://blog.csdn.net/stormbjm/article/details/9107831
準(zhǔn)備工作
-
下載并解壓gcc源碼包
從http://ftp.gnu.org/gnu/gcc 下載一個(gè)你想要編譯的gcc源碼包。 比如下載的是gcc-4.7.2.tar.bz2,然后用輸入解壓命令 tar -xvf 4.7.2.tar.bz2
-
安裝所需的庫(kù)
在使用./configure配置的時(shí)候,可能會(huì)遇到如下錯(cuò)誤: configure: error: Building GCC requires GMP 4.2+, MPFR 2.3.1+ and MPC 0.8.0+.
這說(shuō)明需要用到GMP MPFRMPC 這三個(gè)庫(kù)。 傳送門:GMP下載MPFR下載MPC下載
因?yàn)镸PFR和MPC都依賴于GMP包,所以首先安裝GMP。
$ tar -xvf gmp-5.0.5.tar.bz2
在Linux下手動(dòng)編譯軟件時(shí),要養(yǎng)成建立build目錄的好習(xí)慣,所以建立一個(gè)gmp-5.0.5-build目錄
$ mkdir gmp-5.0.5-build
$ cd gmp-5.0.5-build
$./../gmp-5.0.5/configure (可以使用配置參數(shù)--prefix=指定安裝位置,這里使用默認(rèn) /usr/local/include 和/usr/local/lib)
$make
$make check (這一步用來(lái)確保編譯正確)
$sudo make install
在執(zhí)行configure的時(shí)候可能會(huì)提示錯(cuò)誤:checking for suitable m4... configure: error: No usable m4 in $PATH or /usr/5bin
這就說(shuō)明我們還要安裝m4這個(gè)庫(kù),傳送門:m4
$ tar -xvf m4-1.4.16.tar.bz2
$ mkdir m4-1.4.16-build
$ cd m4-1.4.16-build
$ ./../m4-1.4.16-build/configure
$ make
$ make check
$ sudo make install
$ man m4 (如果可以成功man m4,就說(shuō)明這個(gè)庫(kù)安裝成功)
安裝完m4后,我們繼續(xù)回到之前gmp-5.0.5-build的目錄,繼續(xù)進(jìn)行configure操作。
接著安裝MPFR這個(gè)庫(kù)
$ tar -xvf mpfr-3.1.1
$ mkdir mpfr-3.1.1-build
$ cd mpfr-3.1.1-build
$ ./../mpfr-3.1.1/configure --with-gmp-include=/usr/local/include --with-gmp-lib=/usr/local/lib (由于mpfr依賴于gmp這個(gè)庫(kù),所以在configure時(shí),需要設(shè)置好gmp庫(kù)所在的位置,供安裝mpfr庫(kù)時(shí)使用。)
$ make
$ make check
$ sudo make install
接著安裝MPC這個(gè)庫(kù)
$ tar -xvf mpc-1.0.1
$ mkdir mpc-1.0.1-build
$ cd mpc-1.0.1-build
$ ./../mpc-1.0.1/configure --with-gmp-include=/usr/local/include --with-gmp-lib=/usr/loca/lib
$ make
$ make check
$ sudo make install
需要的庫(kù)都安裝完后,為了防止編譯gcc時(shí)找不到這三個(gè)庫(kù),所以需要確認(rèn)庫(kù)位置是否在環(huán)境變量中 LD_LIBRARY_PATH中
$ echo $LD_LIBRARY_PATH
如果沒有的話,手動(dòng)添加即可
$ export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/usr/local/lib"
為了以后使用的時(shí)候不再設(shè)置,我們可以修改/etc/bashprofile或者/etc/profile。這里修改的是全局變量,對(duì)所有用戶有效,修改~/.bashprofile 和~/.profile可以修改用戶的全局變量。
$ sudo vim /etc/profile
添加以下兩句:
export LD_LIBRARY_PATH=/usr/local/lib
LD_LIBRARYPATH=:/usr/local/gcc-4.7.2/lib:$LD_LIBRARYPATH
保存退出
$ souce /etc/profile
做完這些準(zhǔn)備工作后,就可以開始編譯gcc了
-
構(gòu)建build目錄,開始編譯
$ mkdir gcc-4.7.2-build
$ cd gcc-4.7.2-build
接下來(lái)要執(zhí)行configure進(jìn)行一系列的配置,在[GCC官方網(wǎng)站】(http://gcc.gnu.org/install/configure.html)可以看到一系列的配置。我在編譯的時(shí)候是參考我機(jī)子上原來(lái)的配置進(jìn)行了一點(diǎn)點(diǎn)小改動(dòng)。
我在我的終端下使用
$ gcc -v
出現(xiàn)了一些列的信息: Target: i686-linux-gnu Configured with: ../src/configure -v --with-pkgversion='Ubuntu/Linaro 4.4.4-14ubuntu5.1' --with-bugurl=file:///usr/share/doc/gcc-4.4/README.Bugs --enable-languages=c,c++,fortran,objc,obj-c++ --prefix=/usr --program-suffix=-4.4 --enable-shared --enable-multiarch --enable-linker-build-id --with-system-zlib --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --with-gxx-include-dir=/usr/include/c++/4.4 --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-objc-gc --enable-targets=all --disable-werror --with-arch-32=i686 --with-tune=generic --enable-checking=release --build=i686-linux-gnu --host=i686-linux-gnu --target=i686-linux-gnu Thread model: posix gcc version 4.4.5 (Ubuntu/Linaro 4.4.4-14ubuntu5.1)
上面的配置很多,我挑選了幾個(gè),最后使用configure配置如下:
$ ../gcc-4.7.2/configure --prefix=/usr/local/gcc-4.7.2 --enable-threads=posix --disable-checking --enable-languages=c,c++,objc(或者--enable-threads=posix --disable-checking --disable-multilib --enable-languages=c,c++)
接著執(zhí)行make
$ make
結(jié)果遇到錯(cuò)誤:gengtype.c:923: undefined reference to `lexer_line'
按照網(wǎng)上的方法安裝一些工具和編譯環(huán)境: build-essential bison flex
本來(lái)想裝個(gè)X,用源碼安裝GCC,沒想到又得借助強(qiáng)大的apt-get了 :(
$ sudo apt-get install build-essential bison flex
$ make clean (清除下之前沒成功編譯的文件)
$ make (繼續(xù)make)
又遇到錯(cuò)誤:gengtype.c:923: undefined reference to `lexer_line'
查看build目錄下的config.log (查看log真的很有用!),發(fā)現(xiàn)問題:conftest.c:10: fatal error: ppl_c.h: No such file or directory
上網(wǎng)查閱資料,需要安裝ppl還有cloog的庫(kù).這里有介紹:傳送門
(= = 原諒我再次使用apt-get)
$ sudo apt-get install libppl0.10-dev
$ sudo apt-get install libcloog-ppl-dev
完了之后:
$ make distclean (make clean和make distclean的區(qū)別可以參考:傳送門)
$ make
這次終于make好了,沒有什么錯(cuò)誤。保險(xiǎn)起見,再
$ make check
結(jié)果又有錯(cuò)誤: /bin/bash: autogen: 未找到命令
上網(wǎng)查了下,autogen這個(gè)庫(kù)沒裝,安之!!
$ sudo apt-get install autogen
$ make check
總算是沒什么問題了。接著我們
$ sudo make install
這步很快就執(zhí)行完了。 接者我們用gcc -version 查看,版本還是原來(lái)的gcc4.4,并沒有g(shù)cc4.7.2,這是因?yàn)間cc4.7.2的可執(zhí)行文件還沒有加入到搜索命令路徑中,所以我們要手動(dòng)加入。
-添加新版gcc的可執(zhí)行文件到命令搜索路徑中
首先用which命令查看使用gcc時(shí),系統(tǒng)調(diào)用的是哪個(gè)路徑下的gcc
$ which gcc
$ /usr/bin/gcc (說(shuō)明gcc命令調(diào)用的是這個(gè)路徑下的gcc)
為此,我們要使用ln命令,建立一個(gè)鏈接,讓 /usr/bin/gcc 指向我們安裝目錄下的gcc. 因?yàn)槲抑暗?usr/bin/gcc已經(jīng)指向了gcc4.4,所以,先刪除這個(gè)鏈接。
$ sudo rm /usr/bin/gcc
然后,進(jìn)行將gcc使用軟鏈接到gcc4.7.2
$ sudo ln -s /usr/local/gcc-4.7.2/bin/gcc /usr/bin/gcc
接著,查看下gcc的版本看看有沒有成功!
$ gcc --version
$ gcc (GCC) 4.7.2 Copyright ? 2012 Free Software Foundation, Inc. 本程序是自由軟件;請(qǐng)參看源代碼的版權(quán)聲明。本軟件沒有任何擔(dān)保; 包括沒有適銷性和某一專用目的下的適用性擔(dān)保。
成功了!我們?cè)谟猛瑯拥姆椒ㄖ匦骆溄酉耮++,就能使用g++4.7.2了!
$ which g++
$ /usr/bin/g++
$ sudo rm /usr/bin/g++
$ sudo ln -s /usr/loca/gcc-4.7.2/bin/g++ /usr/bin/g++
$ g++ -version
$ g++ (GCC) 4.7.2 Copyright ? 2012 Free Software Foundation, Inc. 本程序是自由軟件;請(qǐng)參看源代碼的版權(quán)聲明。本軟件沒有任何擔(dān)保; 包括沒有適銷性和某一專用目的下的適用性擔(dān)保。
-
最后,隨便編寫一個(gè)小程序,使用gcc來(lái)測(cè)試一下吧!
另外一篇:
首先在配置gcc的過程中會(huì)出現(xiàn)錯(cuò)誤:gcc configure: error: Building GCC requires GMP 4.2+, MPFR 2.3.1+ and MPC 0.8.0+
說(shuō)明要安裝gcc需要GMP、MPFR、MPC這三個(gè)庫(kù),可從ftp://gcc.gnu.org/pub/gcc/infrastructure/下載相應(yīng)的壓縮包。由于MPFR依賴GMP,而MPC依賴GMP和MPFR,所以要先安裝GMP,其次MPFR,最后才是MPC。這里三個(gè)庫(kù)我用的版本分別是gmp4.3.2,mpfr2.4.2和mpc0.8.1。
先開始安裝GMP。解壓GMP的壓縮包后,得到源代碼目錄gmp-4.3.2。在該目錄的同級(jí)目錄下建立一個(gè)臨時(shí)的編譯目錄,這里命名為gmp-build。然后開始配置安裝選項(xiàng),進(jìn)入gmp-build目錄,輸入以下命令進(jìn)行配置:
../gmp-4.3.2/configure --prefix=/usr/local/gmp-4.3.2
這里--prefix選項(xiàng)代表要將該庫(kù)安裝在哪里,我是裝在/usr/local/gmp-4.3.2目錄下,后面的安裝都會(huì)用到這個(gè)選項(xiàng)。
這時(shí)在gmp的編譯目錄下就會(huì)生成一個(gè)makefile文件,現(xiàn)在開始編譯安裝。
make
make check
sudo make install
這樣就安裝好了gmp。mpfr和mpc的安裝方法與此類似。不過要注意配置的時(shí)候要把依賴關(guān)系選項(xiàng)加進(jìn)去,具體后面兩個(gè)庫(kù)配置命令如下:
../mpfr-2.4.2/configure? --prefix=/usr/local/mpfr-2.4.2 --with-gmp=/usr/local/gmp-4.3.2
../mpc-0.8.1/configure --prefix=/usr/local/mpc-0.8.1 --with-gmp=/usr/local/gmp-4.3.2 --with-mpfr=/usr/local/mpfr-2.4.2
安裝好這三個(gè)庫(kù)之后,就可以正式開始安裝gcc了。
與此前一樣,先建一個(gè)編譯gcc的臨時(shí)目錄gcc-build,進(jìn)入該目錄后配置安裝選項(xiàng):
../gcc-4.4.3/configure --prefix=/usr/local/gcc-4.4.3 --enable-threads=posix --disable-checking --disable-multilib --enable-languages=c,c++ --with-gmp=/usr/local/gmp-4.3.2 --with-mpfr=/usr/local/mpfr-2.4.2 --with-mpc=/usr/local/mpc-0.8.1
gcc的配置選項(xiàng)有很多,具體可以參考gcc源文件目錄下的安裝說(shuō)明。這里只安裝了c和c++的編譯器。(如果不指定編譯的語(yǔ)言,則會(huì)在make時(shí)不通過,爆出某些文件找不到等錯(cuò)誤,所以還是建議在此指定編譯語(yǔ)言為c,c++)然后開始make編譯。為保險(xiǎn)起見,需要在環(huán)境變量LD_LIBRARY_PATH添加前面三個(gè)庫(kù)的位置,鍵入以下命令:
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/mpc-0.8.1/lib:/usr/local/gmp-5.0.1/lib:/usr/local/mpfr-2.4.2/lib
然后重新make編譯,在經(jīng)過漫長(zhǎng)的1小時(shí)等待后,終于編譯完成。在安裝說(shuō)明里面還有測(cè)試這一步,不過那是可選的。直接make install安裝,至此gcc就全部安裝完成了。不過目前還不能使用新版本的gcc,因?yàn)樾掳娴目蓤?zhí)行文件還沒加到命令的搜索路徑中。在這里我為新版的gcc和g++命令分別建立了一個(gè)軟鏈接。進(jìn)入/usr/bin目錄后,鍵入如下命令建立軟鏈接。
sudo ln -s /usr/local/gcc-4.4.3/bin/gcc gcc44
sudo ln -s /usr/local/gcc-4.4.3/bin/g++ g++44
這樣我使用新版本gcc的時(shí)候就可以用gcc44和g++44命令,同時(shí)也可使用原來(lái)的gcc編譯程序。當(dāng)然這里也可以直接將/usr/bin目錄下gcc,g++命令重新鏈接到新版本的gcc可執(zhí)行文件。在正式使用之前還有最后一個(gè)工作要做,就是將前面安裝的三個(gè)庫(kù)的路徑加進(jìn)環(huán)境變量LD_LIBRARY_PATH中,不然在編譯程序的時(shí)候會(huì)出錯(cuò)。由于我不想每次編譯程序都生成環(huán)境變量,所以需要編輯/etc目錄下的bashrc文件配置shell環(huán)境。在這個(gè)文件中添加以下語(yǔ)句:
LD_LIBRARY_PATH=:/usr/local/mpc-0.8.1/lib:/usr/local/gmp-4.3.2/lib:/usr/local/mpfr-2.4.2/lib:/usr/local/gcc-4.4.3/lib
export LD_LIBRARY_PATH
保存重啟系統(tǒng)后,就可以使用新裝的gcc了。
以上就是我在CentOS?5.5安裝gcc4.4.3的全過程。
出現(xiàn)問題make的時(shí)候提示如下:
Checking for suffix of object files... configure: error: in `/home/wulei/sourcecode/gcc-4.6.2/i686-pc-linux-gnu/libgcc':
configure: error: cannot compute suffix of object files: cannot compile
See `config.log' for more details.
make[2]: *** [configure-stage1-target-libgcc] 錯(cuò)誤 1
make[2]:正在離開目錄 `/home/wulei/sourcecode/gcc-4.6.2'
make[1]: *** [stage1-bubble] 錯(cuò)誤 2
make[1]:正在離開目錄 `/home/wulei/sourcecode/gcc-4.6.2'
make: *** [all] 錯(cuò)誤 2
?
于是 進(jìn)入/home/wulei/sourcecode/gcc-4.6.2/i686-pc-linux-gnu/libgcc查看這個(gè)路徑下的config.log
發(fā)現(xiàn)如下的錯(cuò)誤提示:
/home/wulei/sourcecode/gcc-4.6.2/host-i686-pc-linux-gnu/gcc/cc1: error while loading shared libraries: libmpfr.so.1: cannot open shared ob ? ?ject file: No such file or directory
?
上網(wǎng)查找這個(gè)問題
原因是因?yàn)閘inux在make的時(shí)候沒有自動(dòng)尋找新加入的庫(kù)所以要用命令加入
LD_LIBRARY_PATH=/usr/local/mpc-0.8.1/lib:/usr/local/mpfr-2.4.2/lib:/usr/local/gmp-4.3.2/lib
echo $LD_LIBRARY_PATH
export $LD_LIBRARY_PATH
http://www.comdyn.cn/from-web/68-server-setup/164-centos-48-gcc450.html
1? ftp://gd.tuwien.ac.at/gnu/gcc/releases/gcc-4.8.2/ 下載解壓,configure報(bào)錯(cuò), 報(bào)錯(cuò):
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 locations.2 下載/安裝三個(gè)庫(kù); 或者查看?./contrib/download_prerequisites.sh
tar -xvf gmp-5.0.5.tar.bz2
cd gmp-5.0.5
./configure && make && make check && make install;??? 頭文件在/usr/local/inclue/下, 庫(kù)在/usr/local/lib/下
wget http://www.mpfr.org/mpfr-current/mpfr-3.1.2.tar.bz2
tar xvf mpfr-3.1.2.tar.bz2
cd mpfr-3.1.2
./configure --with-gmp-include=/usr/local/include --with-gmp-lib=/usr/local/lib? && make && make install
tar xvf mpc-1.0.tar.gz
cd mpc-1.0
./configure --with-gmp-include=/usr/local/include --with-gmp-lib=/usr/loca/lib --with-mpfr-include=/usr/local/include --with-mpfr-lib=/usr/local/lib
make && make install
/sbin/ldconfig
3 安裝gcc?? https://gcc.gnu.org/install/
./configure --prefix=/usr/local/gcc-4.8.2 --enable-threads=posix --disable-checking --disable-multilib --enable-languages=c,c++ --with-gmp=/usr/local --with-mpfr=/usr/local --with-mpc=/usr/local
make;報(bào)錯(cuò)
centos 5.4 cc1plus: error: unrecognized command line option "-Wno-overlength-strings" g++ (GCC) 4.1.2 20080704 (Red Hat 4.1.2-48) man g++沒發(fā)現(xiàn)有這個(gè)選項(xiàng)。 g++版本低 腫么辦? 好像是4.3加入的這個(gè)選項(xiàng)。 得先升到4.3,再升到4.8 ?. 直接去掉這個(gè)選項(xiàng)試試(安裝成功、程序運(yùn)行也沒多大問題。該選項(xiàng)是和超長(zhǎng)字符串有關(guān)509)。centos 6.4 64位 g++ (GCC) 4.4.7 20120313 (Red Hat 4.4.7-4) 沒這問題configure: error: cannot compute suffix of object files: cannot compile。 將依賴庫(kù)路徑加到搜索路徑下, /sbin/ldconfig
make && make install
然后查看gcc/g++, 讓其指向新裝版本的gcc/g++
有些機(jī)器上回報(bào)錯(cuò) /usr/lib64/libstdc++.so.6: version `GLIBCXX_3.4.14'
strings /usr/lib64/libstdc++.so.6 | grep GLIBC 可以發(fā)現(xiàn)無(wú)3.4.14;
同理將 /usr/lib64/libstdc++.so.6 指向新裝的gcc下的libstdc++.so.6!!!直接指向最新的libstdc++.so.6.0.18, 否則有可能運(yùn)行時(shí)會(huì)報(bào)錯(cuò)GLIBCXX 版本問題
4 安裝新版本gdb
用gdb調(diào)試時(shí),會(huì)報(bào)錯(cuò) Dwarf Error: wrong version in compilation unit header (is 4, should be 2)
從網(wǎng)上搜到的改 gcc選項(xiàng)無(wú)錫哦啊, 看到的棧幀和源代碼。
因此安裝新版本gdb即可。
wget http://ftp.gnu.org/gnu/gdb/gdb-7.8.tar.gz
解壓
./configure && make && make install
總結(jié)
以上是生活随笔為你收集整理的安装gcc 4.8.2 for cxx 11的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: boost signals2 coro
- 下一篇: 栈越界的区别