主要圍繞兩篇推文
Linux下無(wú)root權(quán)限配置GCC環(huán)境 - 知乎 (zhihu.com)
(34條消息) Linux環(huán)境下非root用戶安裝GCC_Bessenn的博客-CSDN博客_非root用戶安裝gcc
我自己試的代碼#centos系統(tǒng)职员,原來(lái)是GCC5.4
conda activate NM2
各版本gcc下載地址 http://ftp.gnu.org/gnu/gcc/,此處下載的是6.2,支持c++14
tar -zxvf gcc-6.2.0.tar.gz
依賴gmp城丧、mpfr每庆、mpc瑟押、gcc廓八,isl好在源碼里自帶下載鏈接京景,不然還得調(diào)試版本
cd gcc-6.2.0/
./contrib/download_prerequisites
創(chuàng)建安裝的文件夾窿冯,因?yàn)闆](méi)有權(quán)限,在自己的目錄下 創(chuàng)建
mkdir envs && cd envs
mkdir gcc gmp isl mpc mpfr
分別編譯各個(gè)軟件确徙,知乎推文介紹說(shuō)是獨(dú)立編譯醒串,但會(huì)報(bào)錯(cuò)执桌,其實(shí)是 mpfr依賴于gmp,mpc依賴于gmp和mpfr
cd /public/home/baoqi/software/gcc-6.2.0/gmp-x.x
./configure prefix=/public/home/baoqi/software/envs/gmp #這里也要改成上面新建的文件夾對(duì)應(yīng)的路徑
make && make install ```
安裝mlfr
cd /public/home/baoqi/software/gcc-6.2.0/mpfr-x.x
./configure --prefix=/public/home/baoqi/software/envs/mpfr --with-gmp-include=/public/home/baoqi/software/envs/gmp/include --with-gmp-lib=/public/home/baoqi/software/envs/gmp/lib
make -j4 #4個(gè)線程
make install
安裝mpc
cd /public/home/baoqi/software/gcc-6.2.0/mpc-0.8.1
./configure --prefix=/public/home/baoqi/software/envs/mpc --with-gmp-include=/gmp安裝路徑/include --with-gmp-lib=/gmp安裝路徑/lib --with-mpfr-include=/mpfr安裝路徑/include --with-mpfr-lib=/mpfr安裝路徑/lib
make -j4
make install
安裝isl
cd /public/home/baoqi/software/gcc-7.2.0/isl-0.16.1 #這里要改成自己的路徑
./configure --prefix=/data2/fangmiaoCV/users/ziwen/envs/isl #這里也要改成上面新建的文件夾對(duì)應(yīng)的路徑
make && make install
## 添加臨時(shí)環(huán)境變量
之所以稱之為臨時(shí)厦凤,是因?yàn)橹貑⒕蜁?huì)失效鼻吮,但無(wú)所謂育苟,因?yàn)檫@個(gè)只是編譯GCC用的较鼓,真正的GCC才是需要的環(huán)境
# 這些路徑改成剛剛新建的路徑
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/data2/fangmiaoCV/users/ziwen/envs/mpc/lib:/data2/fangmiaoCV/users/ziwen/envs/gmp/lib:/data2/fangmiaoCV/users/ziwen/envs/mpfr/lib/:/data2/fangmiaoCV/users/ziwen/envs/isl/lib
cd /home/fangmiaoNLP/ziwen/gcc-7.2.0
# 這里記得改成自己的路徑!
./configure --prefix=/public/home/baoqi/software/envs/gcc --with-gmp=/public/home/baoqi/software/envs/gmp --with-mpfr=/public/home/baoqi/software/envs/mpfr --with-mpc=/public/home/baoqi/software/envs/mpc --with-ils=/public/home/baoqi/software/envs/isl --with-system-zlib --disable-multilib
# 清空環(huán)境變量
unset LIBRARY_PATH CPATH C_INCLUDE_PATH PKG_CONFIG_PATH CPLUS_INCLUDE_PATH INCLUDE
make && make install
這一步如果報(bào)“需要手動(dòng) make distclean”的話违柏,可以考慮把gcc-6.2.0文件夾刪了博烂,重新解壓。(親測(cè)有效)
編譯時(shí)候報(bào)了個(gè)錯(cuò)漱竖,沒(méi)有具體原因顯示禽篱,激活到 NM2就可以了,難不成是和原來(lái)的gcc5.4有關(guān)
wait----確實(shí)時(shí)間很久
#記得改成自己的路徑b扇恰躺率!改成剛剛隨便找的地方創(chuàng)建的gcc文件夾。
vim ~/.bashrc
export PATH=/public/home/baoqi/software/envs/gcc/bin:/public/home/baoqi/software/envs/gcc/lib64:$PATH
export LD_LIBRARY_PATH=/public/home/baoqi/software/envs/gcc/lib/:$LD_LIBRARY_PATH
source ~/.bashrc
test
gcc -v
感想:還是得多看帖子 多嘗試
r日万矾,第二天用的時(shí)候gcc還在悼吱,但是cmake報(bào)錯(cuò)gcc有問(wèn)題,沒(méi)辦法良狈,重新編譯gcc后可用
是以系統(tǒng)自帶的為優(yōu)先級(jí)別