Introduction: Since I was testing and learning on a new virtual machine, I just heard a colleague talk about a friend who was upgrading and installing gcc and causing system problems, so be careful when installing gcc.
[ root@linux-01~]# yum install -y gcc
# Installation process omitted
[ root@linux-01~]# gcc -v
Use built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-redhat-linux/4.8.5/lto-wrapper
Target: x86_64-redhat-linux
Configured as:../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=http://bugzilla.redhat.com/bugzilla --enable-bootstrap --enable-shared --enable-threads=posix --enable-checking=release --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-gnu-unique-object --enable-linker-build-id --with-linker-hash-style=gnu --enable-languages=c,c++,objc,obj-c++,java,fortran,ada,go,lto --enable-plugin --enable-initfini-array --disable-libgcj --with-isl=/builddir/build/BUILD/gcc-4.8.5-20150702/obj-x86_64-redhat-linux/isl-install --with-cloog=/builddir/build/BUILD/gcc-4.8.5-20150702/obj-x86_64-redhat-linux/cloog-install --enable-gnu-indirect-function--with-tune=generic --with-arch_32=x86-64--build=x86_64-redhat-linux
Thread model: posix
gcc version 4.8.520150623(Red Hat 4.8.5-44)(GCC)
[ root@linux-01~]# cat /etc/redhat-release
CentOS Linux release 7.6.1810(Core)
[ root@linux-01~]# wget https://www.python.org/ftp/python/3.9.0/Python-3.9.0.tar.xz
[ root@linux-01~]# tar -xvJf Python-3.9.0.tar.xz
[ root@linux-01~]# cd Python-3.9.0[root@linux-01 Python-3.9.0]# ./configure --prefix=/usr/local/python3 --enable-optimizations --with-ssl
# The first specified installation path,If not specified,During the installation process, the files needed by the software may be copied to other different directories,It is inconvenient to delete software,Copying software is not convenient.
# The second one can improve python10%-20%Code running speed.
# The third is to use ssl to install pip,The error will be mentioned later.[root@linux-01 Python-3.9.0]# make -j4
Try to compile and install Python 3.9.0, but an error is reported during the make process. The error message is as follows:
Could not import runpy module
Traceback(most recent call last):
File "/root/Python-3.9.0/Lib/runpy.py", line 15,in<module>import importlib.util
File "/root/Python-3.9.0/Lib/importlib/util.py", line 2,in<module>from.import abc
File "/root/Python-3.9.0/Lib/importlib/abc.py", line 17,in<module>from typing import Protocol, runtime_checkable
File "/root/Python-3.9.0/Lib/typing.py", line 21,in<module>import collections
SystemError:<built-infunction compile> returned NULL without setting an error
generate-posix-vars failed
make[1]:***[pybuilddir.txt]Error 1
make[1]:Leave directory"/root/Python-3.9.0”
make:***[profile-opt]Error 2
After querying, the cause is: the version of gcc is relatively low, gcc8.1.0 fixes this problem, when using configure to compile and install, remove the –enable-optimizations option, it is a virtual machine environment, I want to try to upgrade GCC test under. So there are the gcc version upgrades in the following, the upgrade encountered errors, I read many posts that are not very complete, and make a record.
Before compiling, you need to install the GCC dependent libraries: gmp, mpfr and mpc. Compilation also relies on compilation tools such as m4. If not, corresponding errors will be reported when configue is executed. At this time, these compilation tools need to be installed first.
GMP is the abbreviation of "GNU MP Bignum Library", which is a GNU open source mathematical operation library
[ root@linux-01~]# wget https://mirrors.tuna.tsinghua.edu.cn/gnu/gmp/gmp-6.1.0.tar.bz2
[ root@linux-01~]# tar xvfj gmp-6.1.0.tar.bz2
[ root@linux-01~]# cd gmp
[ root@linux-01~]# ./configure --prefix=/usr/local/gmp6.1.0[root@linux-01~]# make
[ root@linux-01~]# make install
[ root@linux-01~]# wget https://gcc.gnu.org/pub/gcc/infrastructure/isl-0.18.tar.bz2
[ root@linux-01~]# tar xvfj isl-0.18.tar.bz2
[ root@linux-01~]# cd isl
[ root@linux-01~]# ./configure --prefix=/usr/local/isl0.18--with-gmp-prefix=/usr/local/gmp6.1.0[root@linux-01~]# make
[ root@linux-01~]# make install
mpc is GNU's open source complex digital algorithm, which relies on gmp and mpfr.
# Install mpfr
[ root@linux-01~]# wget https://mirrors.tuna.tsinghua.edu.cn/gnu/mpfr/mpfr-3.1.4.tar.bz2
[ root@linux-01~]# tar xvfj mpfr-3.1.4.tar.bz2
[ root@linux-01~]# cd mpfr
[ root@linux-01 mpfr]# ./configure --prefix=/usr/local/mpfr3.1.4--with-gmp=/usr/local/gmp6.1.0[root@linux-01~]# make
[ root@linux-01~]# make install
mpfr is a GNU open source large number arithmetic library, which relies on gmp.
# Install mpc
[ root@linux-01~]# wget https://mirrors.tuna.tsinghua.edu.cn/gnu/mpc/mpc-1.0.3.tar.gz
[ root@linux-01~]# tar xvfz mpc-1.0.3.tar.gz
[ root@linux-01 mpc]# ./configure --prefix=/usr/local/mpc1.0.3--with-gmp=/usr/local/gmp6.1.0/--with-mpfr=/usr/local/mpfr3.1.4/[root@linux-01~]# make && make install
[ root@linux-01~]# wget ftp://ftp.mirrorservice.org/sites/sourceware.org/pub/gcc/releases/gcc-8.1.0/gcc-8.1.0.tar.xz
- - 2020- 11- 2418:08:04- - ftp://ftp.mirrorservice.org/sites/sourceware.org/pub/gcc/releases/gcc-8.1.0/gcc-8.1.0.tar.xz
=> “gcc-8.1.0.tar.xz”
Resolving host ftp.mirrorservice.org(ftp.mirrorservice.org)...212.219.56.184,2001:630:341:12::184
Connecting to ftp.mirrorservice.org(ftp.mirrorservice.org)|212.219.56.184|:21...connected.
Logging in as anonymous...login successful!
==> SYST ...carry out.==> PWD ...carry out.
==> TYPE I ...carry out.==>CWD(1)/sites/sourceware.org/pub/gcc/releases/gcc-8.1.0...carry out.
==> SIZE gcc-8.1.0.tar.xz ...63372320==> PASV ...carry out.==> RETR gcc-8.1.0.tar.xz ...carry out.
Length: 63372320(60M)(Informal data)100%[========================================================================================================================================================================>]63,372,3203.67MB/s takes 25s
2020- 11- 2418:08:37(2.40 MB/s)- “gcc-8.1.0.tar.xz" saved[63372320][root@linux-01~]# tar -xvJf gcc-8.1.0.tar.xz
[ root@linux-01~]# cd gcc-8.1.0
[ root@linux-01 gcc-8.1.0]# ./configure --prefix=/usr/local/gcc8.1.0--with-gmp=/usr/local/gmp6.1.0--with-mpfr=/usr/local/mpfr3.1.4/--with-isl=/usr/local/isl0.18--with-mpc=/usr/local/mpc1.0.3/
…………
*** 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 fordefault BUILD_CONFIG... bootstrap-debug
checking for--enable-vtable-verify... no
/usr/bin/ld: cannot find crt1.o: No such file or directory
/usr/bin/ld: cannot find crti.o: No such file or directory
/usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-redhat-linux/4.8.5/libgcc_s.so when searching for-lgcc_s
/usr/bin/ld: cannot find -lgcc_s
/usr/bin/ld: cannot find -lc
/usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-redhat-linux/4.8.5/libgcc_s.so when searching for-lgcc_s
/usr/bin/ld: cannot find -lgcc_s
/usr/bin/ld: cannot find crtn.o: No such file or directory
collect2: error: 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.
[ root@linux-01 gcc-8.1.0]# ./configure -enable-checking=release -enable-languages=c,c++-enable-multilib --prefix=/usr/local/gcc8.1.0--with-gmp=/usr/local/gmp6.1.0--with-mpfr=/usr/local/mpfr3.1.4/--with-isl=/usr/local/isl0.18--with-mpc=/usr/local/mpc1.0.3/[root@linux-01 gcc-8.1.0]# make -j4
…………
/root/gcc-8.1.0/host-x86_64-pc-linux-gnu/gcc/cc1: error while loading shared libraries: libisl.so.15: cannot open shared object file: No such file or directory
make[3]:***[s-selftest-c]Error 1
rm gcc.pod
make[3]:Leave directory"/root/gcc-8.1.0/host-x86_64-pc-linux-gnu/gcc”
make[2]:***[all-stage1-gcc]Error 2
make[2]:Leave directory"/root/gcc-8.1.0”
make[1]:***[stage1-bubble]Error 2
make[1]:Leave directory"/root/gcc-8.1.0”
make:***[all]Error 2
[ root@linux-01 gcc-8.1.0]# vim /etc/ld.so.conf
include ld.so.conf.d/*.conf
include /usr/local/lib
[ root@linux-01 gcc-8.1.0]# find /usr/local/lib/ -name 'libisl.so.15'
[ root@linux-01 gcc-8.1.0]# ldconfig
[ root@linux-01 gcc-8.1.0]# rm -rf host-x86_64-pc-linux-gnu
[ root@linux-01 gcc-8.1.0]# find /-name 'libisl.so.15'/root/isl-0.18/.libs/libisl.so.15/usr/local/isl0.18/lib/libisl.so.15[root@linux-01 gcc-8.1.0]# ln -s /usr/local/isl0.18/lib/libisl.so.15/usr/lib64/libisl.so.15
[ root@linux-01 gcc-8.1.0]# vim /etc/ld.so.conf
include ld.so.conf.d/*.conf
include /usr/lib64/
[ root@linux-01 gcc-8.1.0]# ldconfig
[ root@linux-01 gcc-8.1.0]# ldconfig -v |grep libis
ldconfig:Can't right/libx32 for stat operation:No such file or directory
ldconfig:Give the path multiple times"/usr/lib”
ldconfig:Give the path multiple times"/usr/lib64”
ldconfig:Can't right/usr/libx32 for stat operation:No such file or directory
libisl.so.15 -> libisl.so.15
[ root@linux-01 gcc-8.1.0]# ./configure -enable-checking=release -enable-languages=c,c++-enable-multilib --prefix=/usr/local/gcc8.1.0--with-gmp=/usr/local/gmp6.1.0--with-mpfr=/usr/local/mpfr3.1.4/--with-isl=/usr/local/isl0.18--with-mpc=/usr/local/mpc1.0.3/[root@linux-01 gcc-8.1.0]# make -j4
[ root@linux-01 gcc-8.1.0]# make install
[ root@linux-01 gcc-8.1.0]# /usr/local/gcc8.1.0/bin/gcc -v
Use built-in specs.
COLLECT_GCC=/usr/local/gcc8.1.0/bin/gcc
COLLECT_LTO_WRAPPER=/usr/local/gcc8.1.0/libexec/gcc/x86_64-pc-linux-gnu/8.1.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured as:./configure -enable-checking=release -enable-languages=c,c++-disable-multilib --prefix=/usr/local/gcc8.1.0--with-gmp=/usr/local/gmp6.1.0--with-mpfr=/usr/local/mpfr3.1.4/--with-isl=/usr/local/isl0.18--with-mpc=/usr/local/mpc1.0.3/
Thread model: posix
gcc version 8.1.0(GCC)
[ root@linux-01 gcc-8.1.0]# cd ../Python-3.9.0/[root@linux-01 Python-3.9.0]# mv /usr/bin/gcc /usr/bin/gcc4.8.5[root@linux-01 Python-3.9.0]# ln -s /usr/local/gcc8.1.0/bin/gcc /usr/bin/gcc
root@linux-01 Python-3.9.0]# ./configure --prefix=/usr/local/python3 --enable-optimizations --with-ssl
root@linux-01 Python-3.9.0]# make -j4
root@linux-01 Python-3.9.0]# make install
…………
Traceback(most recent call last):
File "<frozen zipimport>", line 520,in _get_decompress_func
ModuleNotFoundError: No module named 'zlib'
During handling of the above exception, another exception occurred:Traceback(most recent call last):
File "<frozen zipimport>", line 568,in _get_data
File "<frozen zipimport>", line 523,in _get_decompress_func
zipimport.ZipImportError: can't decompress data; zlib not available
During handling of the above exception, another exception occurred:Traceback(most recent call last):
File "<string>", line 6,in<module>
File "/root/Python-3.9.0/Lib/runpy.py", line 206,in run_module
mod_name, mod_spec, code =_get_module_details(mod_name)
File "/root/Python-3.9.0/Lib/runpy.py", line 147,in _get_module_details
return_get_module_details(pkg_main_name, error)
File "/root/Python-3.9.0/Lib/runpy.py", line 111,in _get_module_details
__ import__(pkg_name)
File "<frozen zipimport>", line 241,in load_module
File "<frozen zipimport>", line 709,in _get_module_code
File "<frozen zipimport>", line 570,in _get_data
zipimport.ZipImportError: can't decompress data; zlib not available
Traceback(most recent call last):
File "/root/Python-3.9.0/Lib/runpy.py", line 197,in _run_module_as_main
return_run_code(code, main_globals, None,
File "/root/Python-3.9.0/Lib/runpy.py", line 87,in _run_code
exec(code, run_globals)
File "/root/Python-3.9.0/Lib/ensurepip/__main__.py", line 5,in<module>
sys.exit(ensurepip._main())
File "/root/Python-3.9.0/Lib/ensurepip/__init__.py", line 210,in _main
return_bootstrap(
File "/root/Python-3.9.0/Lib/ensurepip/__init__.py", line 129,in _bootstrap
return_run_pip(args +[p[0]for p in _PROJECTS], additional_paths)
File "/root/Python-3.9.0/Lib/ensurepip/__init__.py", line 38,in _run_pip
return subprocess.run([sys.executable,"-c", code], check=True).returncode
File "/root/Python-3.9.0/Lib/subprocess.py", line 524,in run
raise CalledProcessError(retcode, process.args,
subprocess.CalledProcessError: Command '['/root/Python-3.9.0/python', '-c', '\nimport runpy\nimport sys\nsys.path =[\'/tmp/tmp4xj56co0/setuptools-49.2.1-py3-none-any.whl\', \'/tmp/tmp4xj56co0/pip-20.2.3-py2.py3-none-any.whl\'] + sys.path\nsys.argv[1:] = [\'install\', \'--no-cache-dir\', \'--no-index\', \'--find-links\', \'/tmp/tmp4xj56co0\', \'--root\', \'/\', \'--upgrade\', \'setuptools\', \'pip\']\nrunpy.run_module("pip", run_name="__main__", alter_sys=True)\n']' returned non-zero exit status 1.
make:***[install]Error 1
[ root@linux-01 Python-3.9.0]# yum install zlib-devel bzip2 bzip2-devel readline-devel sqlite sqlite-devel openssl-devel xz xz-devel libffi-devel
# Installation error omitted
[ root@linux-01 Python-3.9.0]# make install
[ root@linux-01 Python-3.9.0]# echo 'expoct PATH=$PATH:/usr/local/python3/bin '>>/etc/profile
[ root@linux-01 Python-3.9.0]# source /etc/profile
Recommended Posts