Manually install gcc4.5.0 in centos 4.8

Source: Internet
Author: User
Tags gmp

 

The main body of the article is from the network http://www.cnblogs.com/silverwings/. the installation process of the article is slightly modified.

 

The latest GCC version is 4.5.0. I have manually installed centos (version 4.8) and encountered many problems during the installation process. The following describes the installation process.

 

First, an error occurs during GCC configuration: GCC configure: Error: Building GCC requires GMP 4.2 +, mpfr 2.3.1 + and MCM 0.8.0 +.

Note: To install GCC, you need to install the GMP, mpfr, and MPC libraries. You can download the corresponding compressed packages from ftp://gcc.gnu.org/pub/gcc/infrastructure. Since mpfr depends on GMP, while nmms depends on GMP and mpfr, it is necessary to install GMP first, followed by mpfr, and finally the nmms. Here, the three libraries are available in gmp4.3.2, mpfr2.4.2, and mpc0.8.1.

Install GMP first. Decompress the GMP compressed package, get the source code directory gmp-4.3.2. Create a temporary compilation directory under the directory of the same level. Name it GMP-build. Then, configure the installation options, go to the GMP-build directory, and enter the following command for Configuration:

../Gmp-4.3.2/configure -- prefix =/usr/local/gmp-4.3.2

Here the -- prefix option indicates where the library is to be installed, and I install it in the/usr/local/gmp-4.3.2 Directory, which will be used in subsequent installations.

At this time, a MAKEFILE file will be generated under the GMP compilation directory, and compilation and installation will begin now.

Make

Make check

Sudo make install

In this way, the GMP has been installed. The method for installing mpfr and nmpc is similar. Note that the dependency option should be added during configuration. The configuration commands for the following two libraries are as follows:

../Mpfr-2.4.2/configure -- prefix =/usr/local/mpfr-2.4.2 -- With-GMP =/usr/local/gmp-4.3.2

../Mpc-0.8.1/configure -- prefix =/usr/local/mpc-0.8.1 -- With-GMP =/usr/local/gmp-4.3.2 -- With-mpfr =/usr/local/mpfr-2.4.2

After these three libraries are installed, you can officially start to install GCC.

As before, first create a temporary gcc-build directory for compiling GCC, and then configure the installation options:

../Gcc-4.5.0/configure -- prefix =/usr/local/gcc-4.5.0 -- enable-threads = POSIX -- disable-checking -- disable-multilib -- enable-classes ages = C, C ++

-- With-GMP =/usr/local/gmp-4.3.2 -- With-mpfr =/usr/local/mpfr-2.4.2 -- With-MPC =/usr/local/mpc-0.8.1

There are many GCC configuration options. For details, refer to the installation instructions under the GCC source file directory. Only the C and C ++ compilers are installed here. (If the compilation language is not specified, it will fail during make, and some files cannot be found and other errors are reported. Therefore, we recommend that you specify the compilation language as C, C ++) then start make compilation. To be safe, you must add the location of the first three libraries in the environment variable LD_LIBRARY_PATH. type the following command:

Export LD_LIBRARY_PATH = $ LD_LIBRARY_PATH:/usr/local/mpc-0.8.1/lib:/usr/local/gmp-4.3.2/lib:/usr/local/mpfr-2.4.2/lib

Then re-make the compilation. After a long wait hour, the compilation is completed. This step is also available in the installation instructions, but it is optional. Directly install make install. Now GCC is fully installed. However, the new version of GCC cannot be used yet, because the new version of executable files have not been added to the command search path. Here I have created a soft link for the new GCC and G ++ commands. Enter the/usr/bin directory and type the following command to create a soft link.

Sudo ln-S/usr/local/gcc-4.5.0/bin/GCC gcc45

Sudo ln-S/usr/local/gcc-4.5.0/bin/g ++ 45

In this way, when using the new version of GCC, I can use the gcc45 and G ++ 45 commands, as well as the original GCC Compilation Program. Of course, you can also directly link the GCC and G ++ commands in the/usr/bin directory to the new version of the GCC executable file. Before using the SDK, you have to add the paths of the preceding three libraries to the environment variable LD_LIBRARY_PATH. Otherwise, an error occurs during program compilation. Because I don't want to generate environment variables every time I compile the program, I need to edit the bashrc file in the/etc directory to configure the shell environment. Add the following statement to the file:

LD_LIBRARY_PATH =:/usr/local/mpc-0.8.1/lib:/usr/local/gmp-4.3.2/lib:/usr/local/mpfr-2.4.2/lib:/usr/local/gcc-4.5.0/lib

Export LD_LIBRARY_PATH

After saving and restarting the system, you can use the newly installed GCC.

The above is the whole process of gcc4.5.0 installation in centos 4.8.

 

 

From: http://www.comdyn.cn/from-web/54-others/164-centos-48--gc-

 

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.