C/C++

home

> gccのインストール

gccのインストール

gccインストール手順の備忘録。バージョンはgcc-8.3.0としている。
引用元:オフライン環境でgcc 8.3.0をソースからビルドする

依存関連ソフトウェアのインストール

gccのインストール前に依存関連ソフトウェアをインストールする必要がある。 詳細はgccのディレクトリ内のcontrib/download_prerequisitesで確認できる。 gcc-8.3.0の場合は以下のバージョンが必要である。

  1. gmp-6.1.0
  2. mpfr-3.1.4
  3. mpc-1.0.3
  4. isl-0.18

それぞれのファイルをダウンロードして展開する。gccのインストール先は$HOME/gcc_installとしてこれらのインストールを実行する。

# gmp
tar xvf gmp-6.1.0.tar.bz2
cd gmp.6.1.0
./configure --prefix=$HOME/gcc_install \
            --enable-cxx
make
make check
make install
cd ..
#mpfr
tar xvf mpfr-3.1.4.tar.bz2
cd mpfr-3.1.4
./configure --prefix=$HOME/gcc_install \
            --with-gmp=$HOME/gcc_install
make -s -j4
make -s -j4 check
make install
cd ..
#mpc
tar xvf mpc-1.0.3.tar.gz
cd mpc-1.0.3
./configure --prefix=$HOME/gcc_install \
            --with-gmp=$HOME/gcc_install \
            --with-mpfr=$HOME/gcc_install
make -s -j4
make -s -j4 check
make install
cd ..
# isl
tar xvf isl-0.18.tar.bz2
cd isl-0.18
./configure --prefix=$HOME/gcc_install \
            --with-gmp-prefix=$HOME/gcc_install
make -j4
make check
make install
cd ..

make checkでPASSまたはSKIPのみであれば問題はないだろう。 最後にgccをインストールする。

# gcc
mkdir build && cd build
../configure --disable-multilib \
             --enable-languages=c,c++,fortrun \
             --prefix=$HOME/gcc_install \
             --with-gmp=$HOME/gcc_install \
             --with-mpfr=$HOME/gcc_install \
             --with-mpc=$HOME/gcc_install \
             --with-isl=$HOME/gcc_install
LD_LIBRARY_PATH=$HOME/gcc_install/lib/      # islを読み込むためにパスが必要
make -j4
make install

これにて$HOME/gcc_install/binにgccがインストールされていれば完了である。 最後にパスを通しておく。

~/.bashrc

export PATH=$HOME/gcc_install/bin:$PATH export LD_LIBRARY_PATH=$HOME/gcc_install/lib64:$HOME/gcc_install/lib:$LD_LIBRARY_PATH export LIBRARY_PATH=$HOME/gcc_install/lib64:$HOME/gcc_install/lib:$LIBRARY_PATH

PREVIOUS

HOME

NEXT