(novice) embedded Linux C language programming environment

Source: Internet
Author: User

Embedded Linux C language programming environment has four parts

1. Compiler VI

Basic model of 1.1 VI

1.1.1 Command mode

Enter commands in this mode to control the movement of the screen cursor, delete characters, words or lines, and move the copied paragraphs.

1.1.2 Insert Mode

Press "ESC" key to return to command line mode. Press the letter "I" key into the insert mode, you can write code.

1.1.3 Low-row mode (last line mode)

Command mode, press ":" Key to enter low line mode. such as ": Q" Leave ": w" to save.

2. Compiling the linker GCC

2.1 GCC Compilation Process 4 steps

Pretreatment (pre-processing)

Compiling (compiling)

Compilation (assembling)

Links (linking)

2.2 Process Analysis

2.2.1 The basic syntax used by GCC:

gcc [option | filename]//option Specifies the option filename to compile the file.

2.2.2 Pretreatment (pre-processing) phase

GCC-E-o [target file] [compile file]

The option "-e" causes the compiler to stop compiling at the end of preprocessing, and "-O" is the result of specifying the GCC output. The file ". I" is a pre-processed C source program. The "XXXX.h" file is not compiled

2.2.3 Compilation (compiling) phase

GCC checks the code for errors. After the check is correct, translate the code into assembly language.

Gcc-s-o [target file] [compile file]//Generate ". S" File

2.2.4 Assembly (assembling) stage

Build the ". S" file of the compile phase to the target file gcc-c xxxx.s-o XXXX.O

2.2.5 Link (linking) stage

The system puts the function implementation into a library file named Libc.so.6. The default path is/lib or/usr/lib

GCC Hello.o-o Hello

Run./hello

3. Debugger GDB

3.1 Entering GDB

[[email protected] gdb] #gdb [executable]//first to GCC [filename]-G

3.2 Viewing files

Enter "1" in GDB to see the program's Code

(GDB) L//l (list)

3.3 Set Breakpoint (GDB) b [line number] code to stop before running to the first line (not running to this line)

3.4 Viewing the condition at the breakpoint

(GDB) Info b

3.5 Run Code (GDB) r

3.6 View variable (GDB) p N//"p variable name"

3.7 Observation Variable (GDB) watch n

3.8 Single Step operation (GDB) n//"Next"

3.9 Program continues to run and exit (GDB) C (GDB) q//

4. Project Manager make

is a tool to control the compilation or repeated compilation of code, automatically manage the content, manner and timing of software software compilation, so that programmers can focus on code writing rather than organizational.

  

  

  

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.