linux下GCC安裝

安裝到本地指定目錄复唤,先指定本地目錄為home目錄下的local陶缺。并導(dǎo)入到path中
export LOCAL_LIBS=$HOME/local/
mkdir $LOCAL_LIBS
export PATH=$LOCAL_LIBS/bin:$LOCAL_LIBS/usr/local/bin/:$PATH

開始下載gcc后解壓
下載地址:https://gcc.gnu.org/
tar -zxvf gcc-8.2.0.tar.gz
./configure --prefix=$LOCAL_LIBS
編譯后報錯

configure: error: Building GCC requires GMP 4.2+, MPFR 2.4.0+ and MPC 0.8.0+.

需要依賴 mpc,mpfr念逞,gmp包候衍,
GCC 源碼里自帶腳本可以輕松下載依賴包蛇尚。
./contrib/download_prerequisites
如果能聯(lián)網(wǎng)的話最后成功后是這樣的:
$ ./contrib/download_prerequisites
gmp-6.1.0.tar.bz2: OK
mpfr-3.1.4.tar.bz2: OK
mpc-1.0.3.tar.gz: OK
isl-0.18.tar.bz2: OK
All prerequisites downloaded successfully.

如果不能聯(lián)網(wǎng),則需要自己手動下載到本地
ftp://gcc.gnu.org/pub/gcc/infrastructure/在這個網(wǎng)址中找到需要依賴的三個包塘匣,下載到本地先安裝這三個包
安裝第一個脓豪;是有順序的。

tar jxvf gmp-6.1.0.tar.bz2
./configure --prefix=$LOCAL_LIBS
make
make install

安裝成功忌卤,這里先把安裝成功后的部分信息粘貼在這里扫夜,

Libraries have been installed in:
   /BIGDATA1/cygene_sydu_1/local/lib

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.
----------------------------------------------------------------------
 /bin/mkdir -p '/BIGDATA1/cygene_sydu_1/local/include'
 /usr/bin/install -c -m 644 gmp.h '/BIGDATA1/cygene_sydu_1/local/include'
make  install-data-hook
make[4]: Entering directory `/BIGDATA1/cygene_sydu_1/software/gmp-6.1.0'

+-------------------------------------------------------------+
| CAUTION:                                                    |
|                                                             |
| If you have not already run "make check", then we strongly  |
| recommend you do so.                                        |
|                                                             |
| GMP has been carefully tested by its authors, but compilers |
| are all too often released with serious bugs.  GMP tends to |
| explore interesting corners in compilers and has hit bugs   |
| on quite a few occasions.                                   |
|                                                             |
+-------------------------------------------------------------+

make[4]: Leaving directory `/BIGDATA1/cygene_sydu_1/software/gmp-6.1.0'
make[3]: Leaving directory `/BIGDATA1/cygene_sydu_1/software/gmp-6.1.0'
make[2]: Leaving directory `/BIGDATA1/cygene_sydu_1/software/gmp-6.1.0'
make[1]: Leaving directory `/BIGDATA1/cygene_sydu_1/software/gmp-6.1.0'

第二個

tar  jxvf mpfr-3.1.4.tar.bz2
cd mpfr-3.1.4
./configure --prefix=$LOCAL_LIBS
make 
make install

安裝成功后會有:

Libraries have been installed in:
   /BIGDATA1/cygene_sydu_1/local/lib

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'

安裝第三個:

tar zxvf mpc-1.0.3.tar.gz
cd mpc-1.0.3
./configure --prefix=$LOCAL_LIBS  LDFLAGS="-L/BIGDATA1/cygene_sydu_1/local/lib" CPPFLAGS="-I/BIGDATA1/cygene_sydu_1/local/include"
make
make install

然后安裝gcc

cd gcc-8.2.0
./configure --prefix=$LOCAL_LIBS  LDFLAGS="-L/BIGDATA1/cygene_sydu_1/local/lib" CPPFLAGS="-I/BIGDATA1/cygene_sydu_1/local/include"

安裝報錯:
required isl version is 0.15 or later
下載安裝isl,還是在剛才下載mpc的網(wǎng)址中下載

tar jxvf isl-0.18.tar.bz2
cd isl-0.18
./configure --prefix=$LOCAL_LIBS  LDFLAGS="-L/BIGDATA1/cygene_sydu_1/local/lib" CPPFLAGS="-I/BIGDATA1/cygene_sydu_1/local/include"
make
make install

沒有報錯驰徊,isl安裝完成历谍,
繼續(xù)編譯gcc:

./configure --prefix=$LOCAL_LIBS  LDFLAGS="-L/BIGDATA1/cygene_sydu_1/local/lib" CPPFLAGS="-I/BIGDATA1/cygene_sydu_1/local/include"
···
checking for isl 0.15 or later... yes
The following languages will be built: c,c++,fortran,lto,objc
*** This configuration is not supported in the following subdirectories:
     gnattools gotools target-libada target-libhsail-rt target-libgo target-libffi target-liboffloadmic
    (Any other directories should still work fine.)
checking for default BUILD_CONFIG... bootstrap-debug
checking for --enable-vtable-verify... no
/usr/bin/ld: crt1.o: No such file: No such file or directory
collect2: ld returned 1 exit status
configure: error: I suspect your system does not have 32-bit development libraries (libc and headers). If you have them, rerun configure with --enable-multilib. If you do not have them, and want to build a 64-bit-only compiler, rerun configure with --disable-multilib.

編譯報錯,根據(jù)提示辣垒,加上--disable-multilib參數(shù)再編譯一次

./configure --prefix=$LOCAL_LIBS  LDFLAGS="-L/BIGDATA1/cygene_sydu_1/local/lib" CPPFLAGS="-I/BIGDATA1/cygene_sydu_1/local/include" --disable-multilib
make

make報錯了

In file included from ../.././gcc/c/c-decl.c:53:
../.././gcc/builtins.h:23:17: warning: mpc.h: No such file or directory
In file included from ../.././gcc/c/c-decl.c:53:
../.././gcc/builtins.h:87: error: expected ‘,’ or ‘...’ before ‘(’ token
make[3]: *** [c/c-decl.o] Error 1
make[3]: Leaving directory `/BIGDATA1/cygene_sydu_1/software/gcc-8.2.0/host-x86_64-pc-linux-gnu/gcc'
make[2]: *** [all-stage1-gcc] Error 2
make[2]: Leaving directory `/BIGDATA1/cygene_sydu_1/software/gcc-8.2.0'
make[1]: *** [stage1-bubble] Error 2
make[1]: Leaving directory `/BIGDATA1/cygene_sydu_1/software/gcc-8.2.0'
make: *** [all] Error 2

愁死人了

總結(jié)

當安裝到指定目錄時候,再沒有root權(quán)限的情況下印蔬,可以通過指定LDFLAGS和CPPFLAGS勋桶,將安裝的依賴包的lib和include路徑指定。就可以編譯成功了侥猬,

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
  • 序言:七十年代末例驹,一起剝皮案震驚了整個濱河市,隨后出現(xiàn)的幾起案子退唠,更是在濱河造成了極大的恐慌鹃锈,老刑警劉巖,帶你破解...
    沈念sama閱讀 218,755評論 6 507
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件瞧预,死亡現(xiàn)場離奇詭異屎债,居然都是意外死亡,警方通過查閱死者的電腦和手機垢油,發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 93,305評論 3 395
  • 文/潘曉璐 我一進店門盆驹,熙熙樓的掌柜王于貴愁眉苦臉地迎上來,“玉大人滩愁,你說我怎么就攤上這事躯喇。” “怎么了硝枉?”我有些...
    開封第一講書人閱讀 165,138評論 0 355
  • 文/不壞的土叔 我叫張陵廉丽,是天一觀的道長。 經(jīng)常有香客問我妻味,道長正压,這世上最難降的妖魔是什么? 我笑而不...
    開封第一講書人閱讀 58,791評論 1 295
  • 正文 為了忘掉前任弧可,我火速辦了婚禮蔑匣,結(jié)果婚禮上劣欢,老公的妹妹穿的比我還像新娘。我一直安慰自己裁良,他們只是感情好凿将,可當我...
    茶點故事閱讀 67,794評論 6 392
  • 文/花漫 我一把揭開白布。 她就那樣靜靜地躺著价脾,像睡著了一般牧抵。 火紅的嫁衣襯著肌膚如雪。 梳的紋絲不亂的頭發(fā)上侨把,一...
    開封第一講書人閱讀 51,631評論 1 305
  • 那天犀变,我揣著相機與錄音,去河邊找鬼秋柄。 笑死获枝,一個胖子當著我的面吹牛,可吹牛的內(nèi)容都是我干的骇笔。 我是一名探鬼主播省店,決...
    沈念sama閱讀 40,362評論 3 418
  • 文/蒼蘭香墨 我猛地睜開眼,長吁一口氣:“原來是場噩夢啊……” “哼笨触!你這毒婦竟也來了懦傍?” 一聲冷哼從身側(cè)響起,我...
    開封第一講書人閱讀 39,264評論 0 276
  • 序言:老撾萬榮一對情侶失蹤芦劣,失蹤者是張志新(化名)和其女友劉穎粗俱,沒想到半個月后,有當?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體虚吟,經(jīng)...
    沈念sama閱讀 45,724評論 1 315
  • 正文 獨居荒郊野嶺守林人離奇死亡寸认,尸身上長有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點故事閱讀 37,900評論 3 336
  • 正文 我和宋清朗相戀三年,在試婚紗的時候發(fā)現(xiàn)自己被綠了串慰。 大學(xué)時的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片废麻。...
    茶點故事閱讀 40,040評論 1 350
  • 序言:一個原本活蹦亂跳的男人離奇死亡,死狀恐怖模庐,靈堂內(nèi)的尸體忽然破棺而出烛愧,到底是詐尸還是另有隱情,我是刑警寧澤掂碱,帶...
    沈念sama閱讀 35,742評論 5 346
  • 正文 年R本政府宣布怜姿,位于F島的核電站,受9級特大地震影響疼燥,放射性物質(zhì)發(fā)生泄漏沧卢。R本人自食惡果不足惜,卻給世界環(huán)境...
    茶點故事閱讀 41,364評論 3 330
  • 文/蒙蒙 一醉者、第九天 我趴在偏房一處隱蔽的房頂上張望但狭。 院中可真熱鬧披诗,春花似錦、人聲如沸立磁。這莊子的主人今日做“春日...
    開封第一講書人閱讀 31,944評論 0 22
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽唱歧。三九已至宪摧,卻和暖如春,著一層夾襖步出監(jiān)牢的瞬間颅崩,已是汗流浹背几于。 一陣腳步聲響...
    開封第一講書人閱讀 33,060評論 1 270
  • 我被黑心中介騙來泰國打工, 沒想到剛下飛機就差點兒被人妖公主榨干…… 1. 我叫王不留沿后,地道東北人沿彭。 一個月前我還...
    沈念sama閱讀 48,247評論 3 371
  • 正文 我出身青樓,卻偏偏與公主長得像尖滚,于是被迫代替她去往敵國和親膝蜈。 傳聞我的和親對象是個殘疾皇子,可洞房花燭夜當晚...
    茶點故事閱讀 44,979評論 2 355

推薦閱讀更多精彩內(nèi)容