GCC版本
這個版本的編譯器不適合編譯Python3.9,在編譯時會產生如下的錯誤。我們用這個老版本編譯器編譯一個新的GCC 9.2版。
Could not import runpy module
Traceback (most recent call last):File "Python-3.8.1/Lib/runpy.py", line 15, in <module>import importlib.utilFile "Python-3.8.1/Lib/importlib/util.py", line 14, in <module>from contextlib import contextmanagerFile "Python-3.8.1/Lib/contextlib.py", line 4, in <module>import _collections_abc
SystemError: <built-in function compile> returned NULL without setting an error
generate-posix-vars failed
make[1]: *** [pybuilddir.txt] Error 1
make[1]: Leaving directory `Python-3.8.1'
make: *** [profile-opt] Error 2
下載gcc
wget https://ftp.gnu.org/gnu/gcc/gcc-9.2.0/gcc-9.2.0.tar.xz
tar zxvf gcc-9.2.0.tar.xz
cd gcc-9.2.0/
編譯時出現如下錯誤
configure: error: Building GCC requires GMP 4.2+, MPFR 2.4.0+ and MPC 0.8.0+.
Try the --with-gmp, --with-mpfr and/or --with-mpc options to specify
their locations. Source code for these libraries can be found at
their respective hosting sites as well as at
ftp://gcc.gnu.org/pub/gcc/infrastructure/. See also
http://gcc.gnu.org/install/prerequisites.html for additional info. If
you obtained GMP, MPFR and/or MPC from a vendor distribution package,
make sure that you have installed both the libraries and the header
files. They may be located in separate packages.錯誤信息中說明,安裝gcc需要這三個依賴:GMP 4.2+, MPFR 2.4.0+ and MPC 0.8.0+。錯誤信息,提示了下載頁面的地址:ftp://gcc.gnu.org/pub/gcc/infrastructure/。打開鏈接:ftp://gcc.gnu.org/pub/gcc/infrastructure/。
或者 yum install gmp gmp-devel mpfr mpfr-devel libmpc libmpc-devel
找到需要的三個包地址,下載下來:
wget https://ftp.gnu.org/gnu/gcc/gcc-9.2.0/gcc-9.2.0.tar.xzwget ftp://gcc.gnu.org/pub/gcc/infrastructure/gmp-6.1.0.tar.bz2wget ftp://gcc.gnu.org/pub/gcc/infrastructure/mpfr-3.1.4.tar.bz2wget ftp://gcc.gnu.org/pub/gcc/infrastructure/mpc-1.0.3.tar.gz安裝GMP:
tar -jxvf gmp-6.1.0.tar.bz2
cd gmp-6.1.0
./configure
make && make install
安裝MPFR:
tar -jxvf mpfr-3.1.4.tar.bz2
cd mpfr-3.1.4
./configure
make && make install
安裝MPC:
tar -zxvf mpc-1.0.3.tar.gz
cd mpc-1.0.3
./configure
make && make install編譯安裝會出現/usr/include/gnu/stubs.h:7:27: 錯誤:gnu/stubs-32.h:沒有那個文件或目錄
yum install glibc-devel.i686
mkdir build && cd build
$ ../configure --prefix=/usr/local --disable-multilib --enable-languages=c,c++
$ make && sudo make install移除gcc
yum remove gcc
?
?