How to manually install the gcc4.5.0 compiler on ubuntu10.04
Time: 21:21:23 Source: www.cnblogs.com Author: Edit
This article teaches you how to manually install the gcc4.5.0 compiler in the ubuntu10.04 system. The GCC compiler version that comes with ubuntu10.04 is 4.4.3, and the latest version is 4.5.0.
This article teaches you how to manually install the gcc4.5.0 compiler in the ubuntu10.04 system. The GCC compiler version that comes with ubuntu10.04 is 4.4.3, and the latest version is 4.5.0.
This error occurs when configuring GCC: GCC configure: Error: Building GCC requires GMP 4.2 +, mpfr 2.3.1 + and MCM 0.8.0 +.
It indicates that the GCC installation requires three libraries: GMP, mpfr, and nmpc, and three packages are downloaded from the Internet. Because mpfr depends on GMP, while nmms depends on GMP and mpfr
In order to install GMP first, followed by mpfr, and finally the MPC. The three libraries I use are gmp5.0.1, mpfr2.4.2, and mpc0.8.1.
Install GMP first. Decompress the GMP compressed package, get the source code directory gmp-5.0.1. 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-5.0.1/configure -- prefix =/usr/local/gmp-5.0.1
Here the -- prefix option indicates where the library is to be installed, and I install it in the/usr/local/gmp-5.0.1 Directory, which will be used in subsequent installations. But here again
The system prompts that M4: GMP configure: Error: no usable M4 in $ path or is missing.
/Usr/5bin. M4 is a macro processor.
Check the solution to this problem on the Internet and run the following command to install it:
Sudo aptitude install build-essential M4
After M4 is installed, the configuration is successful again. 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-5.0.1
../Mpc-0.8.1/configure -- prefix =/usr/local/mpc-0.8.1 -- With-GMP =/usr/local/gmp-5.0.1 -- 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-languages ages = C, C ++
-- With-GMP =/usr/local/gmp-5.0.1 -- 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. Then start make compilation. I thought we could achieve it.
Error: Error while loading shared libraries: libmp C. so.2:
Cannot open shared object file: no such file or directory
After finding a solution on the internet, you need to add the environment variable LD_LIBRARY_PATH to point out the location of the first three libraries. type the following command:
Export LD_LIBRARY_PATH = $ LD_LIBRARY_PATH:/usr/local/mpc-0.8.1/lib:/usr/local/gmp-5.0.1/lib:/usr/local/mpfr-2.4.2/lib
Then re-make the compilation. the most depressing thing happened here. When I compiled it halfway, I suddenly reported an error saying that the disk space was insufficient. Now I found that when the fashion system was in use, the classification of the directory was too small, so I had to vomit blood... There is no way to re-compile a partition.
After a long wait of two hours, the compilation was completed. In the installation instructions, there is still a test step, but it is optional and I have no patience to test it. Make directly
Install and install GCC. 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 am for the new version
The GCC and G ++ commands respectively establish a soft link. 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, the/usr/bin directory can also be directly stored here.
The GCC and G ++ commands re-link 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 variables.
LD_LIBRARY_PATH. Otherwise, an error occurs during program compilation. Because I don't want to generate environment variables every time the program is compiled, You need to edit
Configure the shell environment in the bash. bashrc file. Add the following statement to the file:
LD_LIBRARY_PATH =:/usr/local/mpc-0.8.1/lib:/usr/local/gmp-5.0.1/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.