ubuntu安裝gcc不同的版本


服務器ubuntu14.04安裝ns3.29中,顯示gcc版本過低
使用apt-get安裝失敗,ubuntu14.04默認安裝gcc4.8.4,無法下載更高級的gcc版本

先找到資料1,腳本嘗試了,下載不了gcc-6
再嘗試源碼安裝gcc,找到資料2,手動安裝gcc的依賴包和gcc,發現其中的mpfr包的博客中的版本下載不到,新版本嘗試下,對之后的步驟有影響導致最后一個依賴包下載失敗,不過這個博客中有gcc各種版本的下載源比較有用,在此貼出:下載源1(使用過),下載源2
最后找到一個博客,里面有個腳本直接下載編譯所需要的依賴項,嘗試並成功,資料3
編譯完成后,出現:

----------------------------------------------------------------------
Libraries have been installed in:
   /usr/local/lib/../lib64

If you ever happen to want to link against installed libraries
in a given directory, LIBDIR, you must either use libtool, and
specify the full pathname of the library, or use the `-LLIBDIR'
flag during linking and do at least one of the following:
   - add LIBDIR to the `LD_LIBRARY_PATH' environment variable
     during execution
   - add LIBDIR to the `LD_RUN_PATH' environment variable
     during linking
   - use the `-Wl,-rpath -Wl,LIBDIR' linker flag
   - have your system administrator add LIBDIR to `/etc/ld.so.conf'

See any operating system documentation about shared libraries for
more information, such as the ld(1) and ld.so(8) manual pages.

這是告訴你接下來要怎么用。簡單的辦法是在 /etc/ld.so.conf.d 下新建一個文件 local.conf,里邊寫上 /usr/local/lib。然后以 root 權限執行 ldconfig。這樣你的系統才會找得到安裝到 /usr/local/lib 下的庫文件
一般Linux系統缺省不會去/usr/local/lib找庫文件。所以才有上面的警告。除了把該路徑加入ldconfig之外,另外一個辦法是用

./configure --prefix=/usr

來指定安裝到缺省路徑。(有個風險:別覆蓋了系統原有的東西)
參考網頁


免責聲明!

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



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