suse 下的gcc安裝


在付出了一天的努力之后終於在win7系統上面硬盤安裝suse操作系統成功,可是隨之而來的問題居然是沒有安裝GCC,這對我來說是一個不小的打擊,因為很多工作和工具安裝需要通過GCC來編譯,因此我只好求助於百度,搜索了各種攻略,現在把我安裝成功的經驗分享一下。

 

因為suse里面本身沒有cc的編譯工具,所以使用

gcc-4.4.2.tar.bz2這種方式安裝的報告失敗,報告的問題如下:

checking whether ln works... yes
checking whether ln -s works... yes
checking for gcc... no
checking for cc... no
checking for cc... no
checking for cl... no
configure: error: in `/home/lyl2002/gcc-4.4.2':
configure: error: no acceptable C compiler found in $PATH

然后在一個論壇里面建議用rpm的包去安裝,現在找到rpm的地址:

http://213.174.32.130/sles/distribution/9.0/suse/i586/

首先下載cpp-3.3.3-43.24.i586.rpm

嘗試安裝一下:

# rpm -ivh gcc-3.3.3-43.24.i586.rpm 
error: Failed dependencies:
glibc-devel is needed by gcc-3.3.3-43.24
cpp = 3.3.3-43.24 is needed by gcc-3.3.3-43.2

看log是需要安裝上面的兩個依賴,從上面給的地址中download下來

之后安裝GCC這兩個依賴
1)安裝glibc-devel
#rpm -ivh glibc-devel-2.3.3-98.28.i586.rpm 
Preparing...                ########################################### [100%]
1:glibc-devel            ########################################### [100%]

2)安裝cpp
#rpm -ivh cpp-3.3.3-43.24.i586.rpm 
Preparing...                ########################################### [100%]
package cpp-3.3.3-43.41 (which is newer than cpp-3.3.3-43.24) is already installed
file /usr/bin/cpp from install of cpp-3.3.3-43.24 conflicts with file from package cpp-3.3.3-43.41
file /usr/lib/gcc-lib/i586-suse-linux/3.3.3/cc1 from install of cpp-3.3.3-43.24 conflicts with file from package cpp-3.3.3-43.41
file /usr/share/man/man1/cpp.1.gz from install of cpp-3.3.3-43.24 conflicts with file from package cpp-3.3.3-43.41

可以發現系統遭已安裝了cpp,只是版本沖突。

3)執行gcc安裝
# rpm -ivh gcc-3.3.3-43.24.i586.rpm        
error: Failed dependencies:
cpp = 3.3.3-43.24 is needed by gcc-3.3.3-43.24

發現系統還是識別不了cpp

4)強制安裝版本cpp-3.3.3-43.24
# rpm -ivh cpp-3.3.3-43.24.i586.rpm --nodeps --force
Preparing...                ########################################### [100%]
1:cpp                    ########################################### [100%]

5)再次安裝gcc
# rpm -ivh gcc-3.3.3-43.24.i586.rpm 
Preparing...                ########################################### [100%]
1:gcc                    ########################################### [100%]

6)測試gcc
# which gcc
/usr/bin/gcc
#vi test.c
test.c內容如下:
#include <stdio.h>
main()
{
printf("\nGCC is OK!\n\n");

編譯test.c
# gcc -O test.c -o test
生成可執行文件test(通過ls命令可以看到) 運行 test
#./test
屏幕輸出
GCC is OK!
說明GCC程序編譯正確。

7)加入相應的環境變量PATH,LD_LIBRARY_PATH即可。

這樣就完成了Suse安裝gcc的步驟。


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM