DEBIAN 11 因需要而安裝舊版Gcc-8.5.0的解法

看起來Debian 10的系統裝Kernel 4.x版的時候,是用Gcc-8.x版的來編譯。
所以升級到Debian 11之後,因為已經改支援Kernel 5.x版,所以如果因為原來的4.x版要更新驅動程式,要灌linux-headers套件會說沒有安裝到Gcc-8.x版,無法使用。
目前只能改到官網抓來重新編譯,是安全的做法,來個雙Gcc執行環境。

目前看8.x版最後維護的版本是Gcc-8.5.0,所以相關指令就這樣整理:
git clone git://gcc.gnu.org/git/gcc.git
cd gcc
git checkout releases/gcc-8.5.0
(./contrib/download_prerequisites 下載依賴)
(./contrib/gcc_update 下載相關更新補釘)
mkdir build
cd build
../configure --prefix /usr/local/gcc/8.5.0 --disable-multilib
(../configure -enable-checking=release -enable-languages=c,c++ -disable-multilib)
make -j8
sudo make install

看到這個表示大功告成啦!!
----------------------------------------------------------------------
Libraries have been installed in:
/usr/local/gcc/8.5.0/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.
----------------------------------------------------------------------

完成安裝後,若要用舊版的Gcc套件來呼叫需要的程式,只要把環境變數執行告訴系統想要怎麼運作亦可。
指令如下:
export PATH=/usr/local/gcc/8.5.0/bin:$PATH
export LD_RUN_PATH=/usr/local/gcc/8.5.0/lib64
$gcc -v #確認宣告呼叫後Gcc執行的環境版本
$./執行要跑的程式

GCC官方網站:
http://gcc.gnu.org

參考文章:
https://markito3.wordpress.com/tag/gcc-8-3-0/
https://stackoverflow.com/questions/33461938/how-to-apply-a-gcc-patch-in-ubuntu
https://lantern.cool/tool-linux-muti-gcc/
https://blog.csdn.net/liuzq/article/details/89254806
https://imicrobenson.blogspot.com/2011/06/gcc.html

發佈留言

發佈留言必須填寫的電子郵件地址不會公開。 必填欄位標示為 *

請輸入下列驗證碼計算後阿拉伯數字 (Translate it, if not Taiwanese to post reply) *