2018年3月22日 星期四

Debian 7.11上編譯GCC 5.5.0

Debian 7.11 (wheezy)預設的GCC是4.7.2,這邊想要編譯GCC 5.5.0。參考《Installing GCC》一文建議的函式庫版本:
  • GNU Multiple Precision Library (GMP) version 4.3.2 (or later)
  • MPFR Library version 2.4.2 (or later)
  • MPC Library version 0.8.1 (or later)
然後還要先安裝一些軟體:
  • sudo apt-get install gcc-multilib
  • sudo apt-get install autogen
接著依照下面的順序執行:

I. 安裝GMP 6.1.0

  1. wget ftp://gcc.gnu.org/pub/gcc/infrastructure/gmp-6.1.0.tar.bz2
  2. md5sum gmp-6.1.0.tar.bz2
    86ee6e54ebfc4a90b643a65e402c4048  gmp-6.1.0.tar.bz2
  3. tar jxf gmp-6.1.0.tar.bz2 && cd gmp-6.1.0
  4. ./configure --prefix=/opt/gmp-6.1.0
  5. make -j 12
  6. make check
  7. sudo make install


II. 安裝MPFR 3.1.4

  1. wget ftp://gcc.gnu.org/pub/gcc/infrastructure/mpfr-3.1.4.tar.bz2
  2. md5sum mpfr-3.1.4.tar.bz2
    b8a2f6b0e68bef46e53da2ac439e1cf4  mpfr-3.1.4.tar.bz2
  3. tar jxf mpfr-3.1.4.tar.bz2 && cd mpfr-3.1.4
  4. ./configure --prefix=/opt/mpfr-3.1.4-gmp610 \
    --with-gmp=/opt/gmp-6.1.0
  5. make -j 12
  6. make check
  7. sudo make install


III. 安裝MPC 1.0.3

  1. wget ftp://gcc.gnu.org/pub/gcc/infrastructure/mpc-1.0.3.tar.gz
  2. md5sum mpc-1.0.3.tar.gz
    d6a1d5f8ddea3abd2cc3e98f58352d26  mpc-1.0.3.tar.gz
  3. tar zxf mpc-1.0.3.tar.gz && cd mpc-1.0.3
  4. ./configure --prefix=/opt/mpc-1.0.3-mpfr314-gmp610 \
    --with-mpfr=/opt/mpfr-3.1.4-gmp610 \
    --with-gmp=/opt/gmp-6.1.0
  5. make -j 12
  6. make check
  7. sudo make install

IV. 安裝isl Library 0.15

  1. wget ftp://gcc.gnu.org/pub/gcc/infrastructure/isl-0.15.tar.bz2
  2. md5sum isl-0.15.tar.bz2
    8428efbbc6f6e2810ce5c1ba73ecf98c  isl-0.15.tar.bz2
  3. tar jxf isl-0.15.tar.bz2 && cd isl-0.15
  4. ./configure --prefix=/opt/isl-0.15-gmx610 \
    --with-gmp=/opt/gmp-6.1.0
  5. make -j 12
  6. make check
  7. sudo make install

V. 安裝GCC 5.5.0

  1. wget http://ftp.tsukuba.wide.ad.jp/software/gcc/releases/gcc-5.5.0/gcc-5.5.0.tar.gz
  2. shasum -a 512 gcc-5.5.0.tar.gz
    ace0dafc56025b1ed22d06f20b3af2e6c4896b91c36289cfb129dcd6531b53f754150cc69a5b9c6f305598e4d643c80b114ed17cdc93ac979661d31073dd4ffd  gcc-5.5.0.tar.gz
  3. tar zxf gcc-5.5.0.tar.gz && cd gcc-5.5.0
  4. ./configure --prefix=/opt/gcc-5.5.0 \
    --with-isl=/opt/isl-0.15-gmx610 \
    --with-mpc=/opt/mpc-1.0.3-mpfr314-gmp610 \
    --with-mpfr=/opt/mpfr-3.1.4-gmp610 \
    --with-gmp=/opt/gmp-6.1.0
  5. export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/opt/gmp-6.1.0/lib:/opt/mpfr-3.1.4-gmp610/lib:/opt/mpc-1.0.3-mpfr314-gmp610/lib:/opt/isl-0.15-gmx610/lib
  6. make -j 12
  7. make check
  8. sudo make install

VI. 使用GCC 5.5.0編譯程式

  1. export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/opt/gmp-6.1.0/lib:/opt/mpfr-3.1.4-gmp610/lib:/opt/mpc-1.0.3-mpfr314-gmp610/lib:/opt/isl-0.15-gmx610/lib
  2. /opt/gcc-5.5.0/bin/gcc -o hello hello.c
  3. ./hello
export LD_LIBRARY_PATH應該是可以設定在某個檔案裡面,這樣就不用每次要跑都要重新弄一次這個指令。上面的指令將hello.c編譯成為執行檔hello

參考資料

_EOF_

沒有留言:

張貼留言