Android system development (1) -- GCC compiler compilation and Installation Process

Source: Internet
Author: User
Tags gmp

Android system development (1) -- GCC compiler compilation and Installation Process
Introduction to GCC compiler

The GCC Compiler (gng c Compiler) is a compilation system that complies with the ansi c standard in the GNU project. It can compile programs written in C ++ Object C and other languages. At the same time, GCC is also a cross Compiler, especially for Embedded Development on different platforms.

GNU:

GNU is the abbreviation of "GNU is Not Unix". In 1984, Shi Toman started the GNU project to create a Free and open Unix operating system (Free UNIX ), at the beginning, Shi Toman developed functional software based on the software above UNIX. During the development, he did not read the source code of other software (to avoid copyright disputes). Later, due to the free use of GNU software, it is used by many people. And then use the Emacs compiler he has previously written to implement a compiler (GCC) that compiles binary files ). In 1985, a General Public License (GPL) was drafted to prevent free software developed by GNU from being used by others: the copyright system is a means to promote social progress, and copyright itself is not a natural right. (For more information, please go to the GNU Official Website: http://www.gnu.org ).

Ansi c standard:The first standard of C language.

GCC compilation process

GCC help

Input man gcc in Shell to view the GCC help. The following describes the parameters of C language and C ++. <喎?http: www.bkjia.com kf ware vc " target="_blank" class="keylink"> VcD48cD48aW1nIHNyYz0 = "http://www.2cto.com/uploadfile/Collfiles/20140821/2014082110461130.png" alt = "\"/>

The help contains the following parameters:

1. Common Parameters

2. C language Parameters

3. c ++ Parameters

4. object c Parameters

5. language-independent parameters

6. Warning Parameters

7. debugging Parameters

8. optimization parameters

9. compilation process parameters

10. Machine dependency Parameters

The compilation process parameters include the following parameters:

-C ____: Only compilation is not linked and the target file is generated.

-S ____ only compiles without assembly and generates assembly code.

-E ____ only pre-compiled

-G ____ contains debugging information

-O file ____ specifies the target output file

-Ldir ____ search for the header file path

Download and compile the source code of the GCC compiler

Go to the GNU website (www.gnu.org) to find the source code of GCC.


Download the latest version of GCC 4.9.1 released, which has the svn check path. You can use svn to check out your local directory.

The class libraries and tools GCC depends on are described in the official download instruction (https://gcc.gnu.org/install/download.html.

Download and decompress the dependent library and GCC Source Code as follows:

Go to the decompressed gcc file directory, as shown below:

Next we will start to execute the configuration file configure

We can see an error in the configuration LOG. The error content is as follows:

The required class libraries cannot be found during compilation, and the minimum version requirements of these class libraries are provided. Next, let's take a look at the relationships between these dependent class libraries:

Gmp is the GNU multi-precision digital computing class library and relies on m4 (installed by default in most Ubuntu)

Mpfr is a class c class library for multi-precision floating-point operations. It depends on gmp.

As a c class library for complex and high-precision operations, the mpc depends on gmp and mpfr.

Gcc depends on the above class library.

We have figured out these dependencies. Let's start with gmp compilation.

Use./configure -- help/more to view the help information. The default installation address is as follows:

Okay, now we will use the./configure command to complete the following:

Next, run the make command to complete the compilation (which may take some time). After the compilation is complete, run the installation command sudo make install.

Compile other class libraries in the same way.

After mpfr is compiled, the files in the/usr/local/lib directory are as follows (new files starting with libmp fr are added ):

After compilation

Finally, compile the gcc file (after more than one hour)

Note: The system may not find the class library required for gcc compilation, So we add the class library path during compilation, make -- with-gmp =/usr/local/lib -- with-mpfr =/usr/local/lib --

After completion, we can see the gcc executable file in the/usr/local/bin directory. How to verify that this is the gcc we have installed instead of the gcc provided by the system by default? Let's take a look at the version number below:

We can see that the gcc version in the/usr/local/bin directory is 4.9.1. This is the version we downloaded. In addition, we can see that the file was modified today.





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.