Home > System Tutorial > LINUX > body text

Detailed explanation of compiling and installing GCC under CentOS6.8

PHPz
Release: 2024-01-07 16:21:23
forward
1275 people have browsed it

About the default version number of GCC installed through yum under CentOS, CentOS 5 is 4.1.2; CentOS 6 is 4.4.7; CentOS 7 is 4.8.3.

Many times when compiling and installing software, a higher version of GCC is required, otherwise an error will be reported.

So how to upgrade the GCC version?

First, confirm the GCC version number you upgraded to.

Currently, the latest version of GCC has reached 5.2, while CentOS 7 still uses 4.8, so based on compatibility considerations, I chose to upgrade to 4.8.5.

GCC official website: https://www.php.cn/link/421f8eb2f6d635fc5e09d0b16c59e281

Let’s start step by step to compile and install GCC 4.8.5. It should be noted that before compiling and installing GCC, the old version of GCC and dependent libraries must be installed in the system through yum.

If you are compiling under an x86_64 system, you also need to install libgcc.i686 glibc-devel.i686.

yum install -y gcc texinfo-tex flex zip libgcc.i686 glibc-devel.i686

Note: When compiling and installing GCC, the memory must be no less than 1GB, Swap must be no less than 1GB, and the hard disk must be no less than 10GB. Otherwise, it is very likely to exit with an error midway.

After compilation and installation, the directory gcc-4.8.5 will be 5GB.

1. Download source code

wget ftp://ftp.gnu.org/gnu/gcc/gcc-4.8.5/gcc-4.8.5.tar.gz

2. Download dependency packages

Compiling and installing GCC requires dependencies on mpc, mpfr, and gmp packages. Fortunately, the GCC source code comes with a script that can easily download dependency packages.

tar zxf gcc-4.8.5.tar.gz cd gcc-4.8.5 ./contrib/download_prerequisites

Detailed explanation of compiling and installing GCC under CentOS6.8

Detailed explanation of compiling and installing GCC under CentOS6.8

Detailed explanation of compiling and installing GCC under CentOS6.8

Compile and install

# cd gcc-4.8.1

#./gcc-4.8.1/configure--prefix=/usr/local/gcc-4.8.1 --enable-languages=c,c

prefix=/usr/local/gcc-4.8.1 indicates the path to configure the installation. If the installation path is not specified, the executable file will be placed under /usr/local/bin by default. This is done to facilitate maintenance. When needed When uninstalling, just delete the directory directly.

enable-languages ​​means installation language, here it means only c and c

Compile

After the preparation is completed, you can compile

# make

This process takes about 2 hours. If an error is reported midway, it will prompt fatal error: gnu/stubs-32, No such file or directory. As shown below:

Detailed explanation of compiling and installing GCC under CentOS6.8

Run the following command and then recompile

# yum -y install glibc-devel.i686 --setopt=protected_multilib=false

# make

The above is the detailed content of Detailed explanation of compiling and installing GCC under CentOS6.8. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:jb51.net
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!