Fedora15 downgrade installation GCC-4.5.3 process as well as encountered problems and solutions Summary

Source: Internet
Author: User
Tags gmp
In this article about configuring the CUDA environment in Linux (see the http://www.linuxidc.com/Linux/2011-12/49874.htm), the latest CUDA version 4.1 only supports gcc4.6 or earlier, while gcc in my Fedora is 4.6.1, to this end, we need to downgrade the gcc version, which is complicated as long as it involves modifying the gcc version. I use Fedora.

In this article about configuring the CUDA environment in Linux (see the http://www.linuxidc.com/Linux/2011-12/49874.htm), the latest CUDA version 4.1 only supports gcc4.6 or earlier, while gcc in my Fedora is 4.6.1, to this end, we need to downgrade the gcc version, which is complicated as long as it involves modifying the gcc version.

I use Fedora 15. The latest gcc version is 4.6.1.

1.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 +. ThisNote: To install gcc, you need three libraries: GMP, MPFR, and MCM.Download the corresponding compressed package.

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. The three libraries I use are gmp4.2, mpfr2.3.1, and mpc0.8.0.

Install GMP first. Decompress the GMP compressed package, get the source code directory gmp-4.2 (Tar jxvf gmp-4.2.tar.bz2-C/usr/local/Here, unzip the gmp-4.2 to/usr/local /). Create a temporary compilation directory under the directory of the same level, named gmp-build(Mkdir/usr/local/gmp-build). Then, configure the installation options, go to the gmp-build directory, and enter the following command for Configuration:

/Usr/local/gmp-4.2/configure -- prefix =/usr/local/gmp-4.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.


2.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:

/Usr/local/mpfr-2.3.1/configure -- prefix =/usr/local/mpfr-2.3.1 -- with-gmp =/usr/local/gmp-4.2

/Usr/local/mpc-0.8/configure -- prefix =/usr/local/mpc-0.8 -- with-gmp =/usr/local/gmp-4.2 -- with-mpfr =/usr/local/mpfr-2.3.1

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


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

/Usr/local/gcc-4.5.3/configure -- prefix =/usr/local/gcc-4.5.3 -- enable-threads = posix -- disable-checking -- disable-multilib -- enable-classes ages = c, c ++, java-- With-gmp =/usr/local/gmp-4.2 -- with-mpfr =/usr/local/mpfr-2.3.1 -- with-mpc =/usr/local/mpc-0.8

There are many gcc configuration options. For details, refer to the installation instructions under the gcc source file directory. Only c, c ++, and java 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 ++, and java) 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 (specifically ):

Vim/etc/profileTo edit the profile file, you also need to modify the read/write permissionsChmod o + w/etc/profile. Add the following code at the end:

Expor

LD_LIBRARY_PATH = $ LD_LIBRARY_PATH:/usr/local/mpc-0.8/lib:/usr/local/gmp-4.2/lib:/usr/local/mpfr-2.3.1/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. DirectMake installNow, all gcc installation is complete. 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.3/bin/gcc gcc45

Sudo ln-s/usr/local/gcc-4.5.3/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/lib:/usr/local/gmp-4.2/lib:/usr/local/mpfr-2.3.1/lib:/usr/local/gcc-4.5.3/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.2.0 installation on Fedora 15.

 

4.  My gcc and g ++ files under the/usr/bin directory mainly include the following: 

Gcc g ++

Gcc45 g ++ 45

The above line is of the old version4.6.1The following line shows the soft link of the newly installed gcc version 4.5.3 of the lower version (I think it is the gcc version of the lower version ),Now the system executes gcc by default or gcc 4.6.1, and gcc45 is the gcc of 4.5. When compiling other source code, the default gcc version needs to be modified because it is configured in configure, so I renamed the original gcc under this directory to gcc. bak(Mv/usr/bin/gcc. bak), Rename gcc45 gcc(Mv/usr/bin/gcc45/usr/bin/gcc)In this way, my default gcc environment is a lower version.4.5.3G ++(Mv/usr/bin/g ++. bak; mv/usr/bin/g ++ + 45/usr/bin/g ++)Same operation.

When you need to change back to a later version by default, execute the reverse operation, change gcc to gcc45, and change gcc. bak to gcc, which is a later version.4.6.1By default, the change of g ++ is also the same.


5.After installing and restarting gcc, I found that the system was slow and the firefox browser and file system could not be opened. Only the terminal could be opened. It was depressing that the problem had not been completely solved yet, there was another problem, so it took a lot of effort to get it done.

First, enter the command on the terminalFirefoxAnd the error message "Couldn't load XPCOM" is displayed. This is a strange question. I checked it online and found nothing similar. I used firefox 7.0 at the time, and then I upgraded it.Yum update firefoxAfter the update, run the firefox command again. The problem is as follows:

XPCOMGlueLoad error for file/usr/lib/xulrunner-2/libxpcom. so:/usr/local/gcc-4.5.3/lib/libstdc ++. so.6: version 'glibcxx _ 3.4.15 'not found (required by/usr/lib/xulrunner-2/libxul. so)

Couldn't load XPCOM.

Later, I found out the information on the Internet, and it took a great deal of money.

Run the following command:strings /usr/local/gcc-4.5.3/lib/libstdc ++.so.6 | grep GLIBCShown as follows:

GLIBCXX_3.4
GLIBCXX_3.4.1
GLIBCXX_3.4.2
GLIBCXX_3.4.3
GLIBCXX_3.4.4
GLIBCXX_3.4.5
GLIBCXX_3.4.6
GLIBCXX_3.4.7
GLIBCXX_3.4.8

GLIBCXX_3.4.9

GLIBCXX_3.4.10

GLIBCXX_3.4.11

GLIBCXX_3.4.12

GLIBCXX_3.4.13

GLIBCXX_3.4.14
GLIBC_2.0
GLIBC_2.3
GLIBC_2.1
GLIBC_2.1.3
GLIBC_2.3.2
GLIBC_2.2
GLIBCXX_FORCE_NEW
GLIBCXX_DEBUG_MESSAGE_LENGTH

Run again ls  -l  /usr/local/gcc-4.5.3/lib/libstdc ++. So.6Shown as follows:

Lrwxrexrwx. 1 root 19 December 19 19:00/usr/local/gcc-4.5.3/lib/libstdc ++. so.6-> libstdc ++. so.6.0.14

It means the lower version of The gcc-4.5.3'sLibstdc ++. so.6 andLibstdc ++. so.6.0.14 has established a soft connection.

Repeat the above two lines of commands, but only use/usr/lib/Libstdc ++. so.6 is replaced/Usr/local/gcc-4.5.3/lib/libstdc ++. so.6, can be found here include'GLIBCXX_3.4.15 ', and the soft connection is:/Usr/lib/Libstdc ++. so.6-> Libstdc ++. so.6.0.16, apparently refers to the original version of the gcc-4.6.1Libstdc ++. so.6 andLibstdc ++. so.6.0.16 has established a soft connection. And now with the lower version of The gcc-4.5.3, but the lack'GLIBCXX_3.4.15 ',

For earlier versions of gcc-4.5.3Libstdc ++. so.6 andLibstdc ++. so.6.0.16 to establish a soft connection, you should be able to solve this problem.

First copy:Cp/usr/lib/libstdc ++. so.6.0.16/usr/local/gcc-4.5.3/lib/

Then create a soft connection:Ln-s/usr/local/gcc-4.5.3/lib/libstdc ++. so.6.0.16/usr/local/gcc-4.5.3/lib/libstdc ++. so.6

Tried the commandFirefoxAnd the file system can also open the browser. This shows that this method is feasible, although it does not understand the truth.

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.