Android system development (1) -- GCC compiler compilation and installation process, androidgcc

Source: Internet
Author: User
Tags gmp

Android system development (1) -- GCC compiler compilation and installation process, androidgcc
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, is used by many users. Then, use the Emacs compiler he wrote together to compile a binary file (GCC ). 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 ++.

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. Optimized 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 modification implementation is today.






Install linux software in the android system. For example, install a GCC compiler and compile the * c file on the mobile phone.

No. The adb shell supports very few linux commands, and the commands with the same name are not fully functional. In addition, it cannot be run if it can be installed. The android running program runs through the Dalvik virtual machine. The linux kernel only provides core system services and serves as an abstract layer between hardware and software. It does not provide a complete linux system by providing a unified hardware operation method for the upper-layer real system, does not have an operating layer for a complete linux system. The bone package of Android 2.3, that is, the most streamlined system package, is less than MB. From this perspective, you should know why it doesn't work? I am not sure about this explanation. I hope it will help you.

Let's look at the GCC compiler.

The porting versions of gcc on windows include mingw and cygwin. You can use the as and ld in binuitls in gcc to compile and link Assembly Code. However, the syntax is AT&T, which is weird, the feature is an open-source compiler. Generally, all aspects of the compiler are similar to vc, but gcc must provide better support for c/c ++ standards, it is a set of universal compilers in the UNIX world. win32 can also use gcc to develop windows programs using gtk +, qt, and other graphics libraries licensed by GPL.

In windows, I have seen two ides, one dev-c ++ and one mingw studio. The following is the address:
Download Dev-C ++: sourceforge.net/projects/dev-cpp/ from sourceforge/
Download Mingw Studio: www.duote.com/soft/9863.html

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.