Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to install the gcc compiler for redhat linux

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

This article introduces the knowledge of "how to install the gcc compiler in redhat linux". Many people will encounter such a dilemma in the operation of actual cases, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!

There are two situations:

General idea of Linux Software installation

In Linux systems, software installers are complicated, but there are two most common ones:

1) one is the source code of the software, and you need to compile it yourself. This software installation package is usually a gzip-compressed tar package (suffixed with .tar.gz).

2) the other is the executable program of the software, you just need to install it. This software installation package is usually referred to as a RPM package (Redhat Linux Packet Manager, which is the package manager for Redhat), with the suffix .rpm.

Of course, there are also source code packaged in rpm format and executable packages compressed in gzip. As long as you understand the following ideas, these two forms of installation packages are fine.

Below, we are divided into two parts to illustrate the idea of software installation:

Part one: fix .tar.gz

1. First, use tar-xzvf to unlock the package, such as:

# tar-xzvf apache_1_3_6_tar.gz

This creates a new directory in the current directory (the directory name is similar to the file name of the .tat.gz package) to store the unzipped content. As in this case, it is apache_1.3.6.

two。 Enter this directory and use the ls command to view the included files, such as:

# cd apache_1.3.6

# ls

You can see which of the following files are contained in this directory: configure, Makefile, or Imake.

1) if it is a configure file, execute:

#. / configure

# make

# make install

2) if it is a Makefile file, execute:

# make

# make install

3) if it is an Imake file, execute:

# xmkmf

# make

# make install

3. If there is no wrong prompt, it will be done. As for where the software is installed, it usually occurs during installation. Otherwise, you can only check README, or ask me,: -)

If you encounter an error prompt, don't worry, it's usually a very simple question:

1) No C or C++ compiler installed

Method of diagnosis: execute the command gcc (Gmail + on C++), indicating that the command cannot be found.

Solution: mount the Linux installation CD, then go to the RPMS directory and execute the command:

# rpm-ivh gcc* (, we used the second installation method)

2) make tools are not installed

Method of diagnosis: execute the command make, indicating that the command cannot be found.

Solution: mount the Linux installation CD, then go to the RPMS directory and execute the command:

# rpm-ivh make*

3) autoconf tools are not installed

Method of diagnosis: execute the command make, indicating that the command cannot be found.

Solution: mount the Linux installation CD, then go to the RPMS directory and execute the command:

# rpm-ivh autoconf*

4) some link libraries are missing

Method of diagnosis: in make, you are prompted to need certain documents.

Solution: install the package that contains this file, which needs to be accumulated.

Part two: get .rpm.

RPM is a software package manager launched by Red Hat company with Redhat Linux, through which software installation can be realized more easily.

1. Install software: execute the rpm-ivh rpm package name, such as:

# rpm-ivh apache-1.3.6.i386.rpm

two。 Upgrade the software: execute the rpm-Uvh rpm package name.

3. Reverse installation: execute the rpm-e rpm package name.

4. Query package details: execute rpm-qpi rpm package name

5. Query which rpm package a file belongs to: execute the rpm-qf rpm package name

6. Find out which files the package will write to the system: execute the rpm-qpl rpm package name

[legacy problem: there is Redhat Linux Packet Manager on the redhat linux system, which is the package manager of Redhat, so if the original machine does not have a gcc compiler, you can download the appropriate rpm package directly when you install the compiler in binary format. But what about other variants of linux? Is there a binary compiler software in the corresponding format or is it possible to use redhat's rpm?]

-ANSWER: other distributions also have corresponding package managers, such as debian's package manager called dpkg,gentoo seems to be able to merge and so on.

Next, first to an article on the installation of executable programs, explain that the machine I use is the redhat9.0 strike version, so I downloaded the corresponding version of the is0 CD-ROM influence file (3 disks) on the school ftp, and virtual out three disks with a virtual optical drive, which is convenient to find other packages in dependent rpm format. Basically, I installed the same process as his, except that it also installed an extra binutils.

-- begin

Detailed steps for installing gcc in quick linux

[author: masenger reposted from: unknown source: number of clicks: 493Article input: admin]

Detailed steps for installing gcc in quick linux

-masenger. 2004-2005

The things you need are:

Glibc-devel-2.3.2-11.9.i386.rpm

Glibc-kernheaders-2.4-8.10.i386.rpm

Gcc-3.2.2-5.i386.rpm

Cpp-3.2.2-5.i386.rpm

I have three CDs in my hand (red hat linux 9.0)

I want to install the gcc compiler and search in three CDs. If you don't have these three CDs, you can download them on my website.

You can also search for downloads on internet.

Http://mirrors.kernel.org/redhat/redhat/linux/9/en/os/i386/RedHat/RPMS/

Found on the second CD: gcc-3.2.2-5.i386.rpm

Now transfer it from ftp to my linux and copy it to the / root/install directory

[root@masenger root] # cd install

[root@masenger install] # ls

Gcc-3.2.2-5.i386.rpm telnet-server-0.17-25.i386.rpm

Install gcc:

[root@masenger install] # rpm-ivh gcc-3.2.2-5.i386.rpm

Warning: gcc-3.2.2-5.i386.rpm: V3 DSA signature: NOKEY, key ID db42a60e

Error: Failed dependencies:

Cpp = 3.2.2-5 is needed by gcc-3.2.2-5

Glibc-devel > = 2.2.90-12 is needed by gcc-3.2.2-5

Thus you can see that at least version 2.2.90 of glibc-devel is required. Search the CD and find it.

Transfer it from ftp to my linux and copy it to the / root/install directory

[root@masenger install] # ls

Gcc-3.2.2-5.i386.rpm glibc-devel-2.3.2-11.9.i386.rpm telnet-server-0.17-25.i386.rpm

Install glibc-devel:

[root@masenger install] # rpm-ivh glibc-devel-2.3.2-11.9.i386.rpm

Warning: glibc-devel-2.3.2-11.9.i386.rpm: V3 DSA signature: NOKEY, key ID db42a60e

Error: Failed dependencies:

Kernel-headers is needed by glibc-devel-2.3.2-11.9

Kernel-headers > = 2.2.1 is needed by glibc-devel-2.3.2-11.9

Thus you can see that at least version 2.2.1 of kernel-headers is required. Search the CD and find it.

But you didn't find it was called kernel-headers. But there's a glibc-kernheaders-2.4-8.10.i386.rpm.

Transfer it from ftp to my linux and copy it to the / root/install directory

[root@masenger install] # ls

Gcc-3.2.2-5.i386.rpm glibc-kernheaders-2.4-8.10.i386.rpm

Glibc-devel-2.3.2-11.9.i386.rpm telnet-server-0.17-25.i386.rpm

Install kernel-headers:

[root@masenger install] # rpm-ivh glibc-kernheaders-2.4-8.10.i386.rpm

Warning: glibc-kernheaders-2.4-8.10.i386.rpm: V3 DSA signature: NOKEY, key ID db42a60e

Preparing... # [100%]

1:glibc-kernheaders # # [100%]

Install glibc-devel:

[root@masenger install] # rpm-ivh glibc-devel-2.3.2-11.9.i386.rpm

Warning: glibc-devel-2.3.2-11.9.i386.rpm: V3 DSA signature: NOKEY, key ID db42a60e

Preparing... # [100%]

1:glibc-devel # # [100%]

Install gcc:

[root@masenger install] # rpm-ivh gcc-3.2.2-5.i386.rpm

Warning: gcc-3.2.2-5.i386.rpm: V3 DSA signature: NOKEY, key ID db42a60e

Error: Failed dependencies:

Cpp = 3.2.2-5 is needed by gcc-3.2.2-5

Also remind you that you need at least version 3.2.2-5 of cpp. Search the CD and find it.

Transfer it from ftp to my linux and copy it to the / root/install directory

Install cpp:

[root@masenger install] # rpm-ivh cpp-3.2.2-5.i386.rpm

Warning: cpp-3.2.2-5.i386.rpm: V3 DSA signature: NOKEY, key ID db42a60e

Preparing... # [100%]

1:cpp # # [100%]

Install gcc:

[root@masenger install] # rpm-ivh gcc-3.2.2-5.i386.rpm

Warning: gcc-3.2.2-5.i386.rpm: V3 DSA signature: NOKEY, key ID db42a60e

Preparing... # [100%]

1:gcc # # [100%]

That's it. Gcc is ready.

-end

People who haven't tried to install the source code are unhappy, so press it and try the gcc compiler in the source code format. I downloaded version 3.4.1 of gcc (gcc-3.4.1.tar.gz). Basically according to the following article, although the introduction in the INSTALL directory on the gnu website and in the gcc decompressed file directory is very complete, I still feel that the foreign code is not as comfortable as our Chinese, .

-begin

The latest version of the GCC compiler 3.4.0 was released on April 20, 2004. At present, GCC can be used to compile programs in languages such as CAccord +, FORTRAN, JAVA, OBJC, ADA, etc., and you can choose which languages to install according to your needs. GCC 3.4.0 supports the C++ standard better than previous versions. Taking the installation of GCC3.4.0 on Redhat Linux as an example, this paper introduces the installation process of GCC.

Before installation, a compiler such as cc or gcc must be available on the system, or the compiler on the system must be specified with the environment variable CC. If you do not have a compiler on your system, you cannot install GCC 3.4.0 in source code. If this is the case, you can find a binary GCC package suitable for your system, such as RPM, to install and use. This article describes the installation process of the GCC software package provided in source code. The package itself and its installation process are also applicable to other Linux and Unix systems.

The original GCC compiler on the system may have stored gcc and other command files, library files, header files and so on in different directories in the system. Instead, GCC now recommends that we install a version of GCC in a separate directory. The advantage of this is that you can easily delete the entire directory when you don't need it in the future (because GCC doesn't have the uninstall feature); the disadvantage is that you have to do some setup work to make the compiler work properly after installation. In this article, I used this scheme to install GCC 3.4.0, and after the installation is complete, I can still use the original lower version of the GCC compiler, that is, multiple versions of the GCC compiler can exist on one system at the same time.

Following the steps and setup options provided in this article, you can install a working new version of the GCC compiler on your system even if you have not previously installed GCC.

1. download

Download resources can be found on the GCC website (http://gcc.gnu.org/) or through an online search. Currently, the latest version of GCC is 3.4.0. There are generally two forms of files available for download: gcc-3.4.0.tar.gz and gcc-3.4.0.tar.bz2, but the compressed format is different and the content is exactly the same, so download one of them.

two。 Decompress

According to the compressed format, choose one of the following methods to unpack (the following "%" represents the command line prompt):

% tar xzvf gcc-3.4.0.tar.gz

Or

% bzcat gcc-3.4.0.tar.bz2 | tar xvf-

The newly generated gcc-3.4.0 directory is called the source directory and is represented by ${srcdir}. In the future, where ${srcdir} appears, you should replace it with the real path. You can view the current path with the pwd command.

There are detailed GCC installation instructions in the ${srcdir} / INSTALL directory, which can be read by opening index.html in a browser.

3. Establish a target directory

The target directory (represented by ${objdir}) is the place where the compiled results are stored. GCC recommends that compiled files not be placed in the source directory ${srcdir] (although this is fine), it is best to store them in a separate directory, and cannot be a subdirectory of ${srcdir}.

For example, you can create a destination directory called gcc-build (which is the same level as the source directory ${srcdir}):

% mkdir gcc-build

% cd gcc-build

The following operations are mainly done under the target directory ${objdir}.

4. Configuration

The purpose of the configuration is to decide where to install the GCC compiler (${destdir}), what language to support, and to specify other options. Where ${destdir} cannot be the same as the ${objdir} or ${srcdir} directories.

Configuration is done by executing configure under ${srcdir}. The format of the command is (remember to replace ${destdir} with your real path):

% ${srcdir} / configure-- prefix=$ {destdir} [other options]

For example, if you want to install GCC 3.4.0 into the / usr/local/gcc-3.4.0 directory, ${destdir} represents this path.

On my machine, I configure it like this:

%.. / gcc-3.4.0/configure-prefix=/usr/local/gcc-3.4.0-- enable-threads=posix-- disable-checking-- enable--long-long-- host=i386-redhat-linux-- with-system-zlib-- enable-languages=c,c++,java

Install GCC in the / usr/local/gcc-3.4.0 directory and support the Cramp Clipper + and JAVA languages. For other options, see the help instructions provided by GCC.

5. Compile

% make

It's a long process. On my machine (P4-1.6), this process took more than 50 minutes.

6. Installation

Execute the following command to copy the compiled library files into the ${destdir} directory (administrator permission may be required depending on the path you set):

% make install

At this point, the GCC 3.4.0 installation process is complete.

6. Other settin

All files of GCC 3.4.0, including command files (such as gcc, Gmail +), library files, etc. are stored in the ${destdir} directory, such as command files in the bin directory, library files in the lib, header files in the include, and so on. Since the directory where the command and library files are located is not yet included in the corresponding search path, the compiler must make appropriate settings before the compiler can successfully find and use them.

6.1Settings of gcc, Gmail + and gcj

To use commands such as gcc in GCC 3.4.0, the easy way is to put its path ${destdir} / bin in the environment variable PATH. Instead of doing this, I do it in symbolic concatenation, which has the advantage that I can still use the old version of the GCC compiler on the system.

First, look at the path where the original gcc is located:

% which gcc

On my system, the above command shows: / usr/bin/gcc. Therefore, the original gcc command is in the / usr/bin directory. We can make a symbolic connection to the commands such as gcc, Gmail + and gcj in GCC 3.4.0 in the / usr/bin directory:

% cd / usr/bin

% ln-s ${destdir} / bin/gcc gcc34

% ln-s ${destdir} / bin/g++ galleys 34

% ln-s ${destdir} / bin/gcj gcj34

In this way, the C, C++ and JAVA programs can be compiled by calling gcc, Gmail + and gcj of GCC 3.4.0 using gcc34, Group34 and gcj34 respectively. At the same time, you can still use commands such as gcc, Gmail +, and so on, from older versions of the GCC compiler.

6.2 setting of library path

Add the ${destdir} / lib path to the environment variable LD_LIBRARY_PATH, preferably to the system's configuration file, so that it is not necessary to set this environment variable every time.

For example, if GCC 3.4.0 is installed in the / usr/local/gcc-3.4.0 directory, you can execute it directly on the command line under RH Linux or add the following sentence to the file / etc/profile:

Setenv LD_LIBRARY_PATH / usr/local/gcc-3.4.0/lib:$LD_LIBRARY_PATH

7. test

Compile your previous C, C++ programs with new compilation commands (gcc34, glossary 34, etc.) and verify that the newly installed GCC compiler works.

8. You can delete or keep the ${srcdir} and ${objdir} directories as needed.

Postscript:

Just installed GCC 3.4.0 two days ago, the installation planning, installation process, some points for attention to record the formation of this article. I hope it will be helpful to all of you, especially those who have not installed GCC, when installing GCC.

This is the end of the content of "how to install the gcc compiler for redhat linux". Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report