Add a lower version of GCC to fedora15 and coexistence of multiple versions of GCC

Source: Internet
Author: User

1. Download the earlier version gcc3.4.6.

2. Su
Yum install compat-gcc-34 *

3.1 first download gcc-3.4.6.tar.bz2 file in the/tmp directory, and extract it, so under/tmp has a gcc-3.4.6 directory, it is the source directory of the gcc-3.4.6
3.2, create a gcc-3.4.6-bulid directory under/tmp, as the target directory of the gcc-3.4.6.
3.3. Create a gcc-3.4.6-dest directory under/usr/local as the configuration directory of the gcc-3.4.6. (Root permission is required, so we can do this: sudo mkdir/usr/local/gcc-3.4.6-dest)
3.4, under the gcc-3.4.6-bulid directory (required), execute the following command:
/Tmp/gcc-3.4.6/configure -- prefix =/usr/local/gcc-3.4.6-dest -- enable-threads = POSIX -- disable-checking -- enable -- long-long -- With-system-zlib -- enable- ages = C, c ++

3.5. Make Bootstrap

3.6. make install

4. view the original GCC path: % which gcc
Display:/usr/local/ccache/GCC
/Usr/local/ccache/is the original GCC directory
5, the GCC, G ++ and other commands in the GCC-3.4.6 in the/usr/local/ccache/directory respectively do a symbolic connection:
> Cd/usr/local/ccache/
> Sudo ln-S/usr/local/gcc-3.4.6-dest/bin/GCC gcc346
> Sudo ln-S/usr/local/gcc-3.4.6-dest/bin/g + + G + + 346 due to errors when adding Java to make in configure, it was not added later.
In principle, this can respectively use gcc346, G ++ 346 to call the GCC-3.4.6 GCC, G ++ J to complete the C, C ++ program compilation. At the same time, you can still use GCC, G ++, and other commands in the earlier version of GCC compiler.
6. Set the library path
Add the $ {destdir}/lib path to the environment variable LD_LIBRARY_PATH. It is best to add it to the system configuration file.
So that you do not need to set this environment variable every time. You can directly execute the command line or Add the following sentence to the file/etc/profile:
> Sudo VI/etc/profile
Setenv LD_LIBRARY_PATH/usr/local/gcc-3.4.6/lib: $ LD_LIBRARY_PATH
7. test whether the new compilation command (gcc346, G ++ 346) works properly.
Just enter the command: gcc346-V
If the following information is displayed, the operation is successful:
Reading specs from/usr/lib/gcc-3.4.6/lib/GCC/i686-pc-linux-gnu/3.4.6/specs
Configured :. /configure -- prefix =/usr/lib/gcc-3.4.6 -- enable-threads = POSIX -- disable-checking -- enable -- long-with-system-zlib -- enable-classes ages = C, c ++
Thread model: POSIX
GCC version 3.4.6

If you are not at ease, compile a simple hello. C program, such
# Include <stdio. h>
Int main (void) {printf ("Hello, fedora15! \ N ");}
Compile: gcc346-O hello. c
If a target Hello file appears, execute./hello and output: Hello, fedora15!
OK.

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.