Install the latest gcc4.2.2 in Linux
Very simple. First of all, the latest package GCC 4.2.bz2 is usually available everywhere. The download speed in Linux is very full, more than 20 K, which is disgusting. I like the download speed of thunder, download in windows, about 42 m, download speed 2 to 4 m, return to Linux, mount, NTFS format me, not to mention it, say install!
Go to the mounted directory, CP gcc4.2.bz2/azuo first,
CD/azuo,
Tar-xvf GCC 4.2.bz2,
Get gcc-4.2,
CD gcc-4.2, creating a folder under the/usr directory is now the directory to store the new GCC,
Mkdir/usr/gcc4
./Configure-Prefix =/usr/gcc4
Press enter and there will be configuration information, as long as no error is reported,
Make, this process has been a long time, because I have not set some specific options, so almost all components need to be compiled once, my computer CPU: AMD 3200 + X2, GB memory, it takes about one and a half hours.
By this time, nothing has been found in/usr/gcc4, and the compilation process occurs in the source folder. Let's take another action, all the things to be used will be configured under the target folder,
Make install;
This process is not short. Just wait.
After everything is done, you can use the latest GCC. You can see that GCC, G ++, and other things in/usr/gcc4/bin are available, write two programs:
AA. C:
1 # include <stdio. h>
2
3 int main (void ){
4 printf ("ad ");
5 return 1;
6}
Gcc-o aa. c
Run./AA
The above is C, and the following is C ++:
A. cpp:
1 # include <iostream>
2 using namespace STD;
3 int main (void ){
4 cout <"OK! "<Endl;
5 return 1;
6}
G ++-o a. cpp
Run it./
If everything is okay, you can replace the original GCC tool with the latest one.
Let's take a look at the original GCC version, so we can uninstall it:
[Root @ btazuo bin] # rpm-Qa gcc
Gcc-4.1.2-27.fc7
[Root @ btazuo bin] # rpm-e gcc-4.1.2-27.fc7
Error: Failed dependencies:
GCC is needed by (installed) systemtap-0.5.13-1.fc7.i386
GCC = 4.1.2-27. fc7 is needed by (installed) GCC-C ++-4.1.2-27. fc7.i386
GCC = 4.1.2-27. fc7 is needed by (installed) GCC-gfortran-4.1.2-27. fc7. i386
[Root @ btazuo bin] # rpm-e gcc-C ++-4.1.2-27. fc7.i386
[Root @ btazuo bin] # rpm-e gcc-gfortran-4.1.2-27.fc7.i386
[Root @ btazuo bin] # rpm-e gcc-4.1.2-27.fc7
Error: Failed dependencies:
GCC is needed by (installed) systemtap-0.5.13-1.fc7.i386
[Root @ btazuo bin] # G ++
Bash: G ++: Command not found
Uninstalled successfully
[Root @ btazuo bin] # gcc
GCC: no input file.
[Root @ btazuo bin] # rpm-e systemtap-0.5.13-1.fc7.i386
[Root @ btazuo bin] # gcc
GCC: no input file
[Root @ btazuo bin] # rpm-e gcc-4.1.2-27.fc7
[Root @ btazuo bin] # gcc
Bash:/usr/lib/ccache/GCC: the file or directory does not exist.
The last unmount is successful!
At this time, please note that my GCC is under/usr/bin and under/usr/lib/ccache, create a link for both of the following:
[Root @ btazuo bin] # ln-S/usr/gcc4/bin/g ++
[Root @ btazuo bin] # G ++
G ++: no input file
It can be seen that G ++ has been installed and can be used.
Then GCC:
[Root @ btazuo bin] # ln-S/usr/gcc4/bin/GCC gcc
[Root @ btazuo bin] # gcc
Bash:/usr/lib/ccache/GCC: the file or directory does not exist.
[Root @ btazuo bin] #./GCC
GCC: no input file
You can also create a GCC link for another directory:
[Root @ btazuo lib] # ln-S/usr/gcc4/bin/GCC/usr/lib/ccache/GCC
[Root @ btazuo lib] # gcc
GCC: no input file
So far, both GCC and G ++ have been established and can be used. Finally, the original package and decompression files can be deleted to save hard disk space! Hoho!