C Language Development tools

Source: Internet
Author: User
Tags gdb debugger

1. Tools for writing Programs:

The indent command automatically adjusts the indentation style of the C code, and the individual prefers INDENT-KR

2. Compile the C language program:

1.GCC Compiler:

GCC is an ANSI C-compatible compiler, and the C + + compiler can also compile the program, and in fact the g++ compiler internally calls the GCC

The GCC command launches the C compile system, which, when executing GCC, completes the preprocessing, compiling, assembling, and connecting 4 steps and eventually generates executable code, which is saved as the A.out file by default. The various file types processed by GCC include:

Static link libraries (. a), Shared link libraries (. So), C language source files (. c), C + + source files (. C\.C or. cpp), assembly language files (. s), preprocessing files (. i), Target code files (. O)

gcc [options] filename-list Note You cannot follow a set of options after a single connection character

2. Function library:

Standard system library files are generally stored in the Linux file system/lib and/usr/lib directories.

By default, the C language compiler searches only the standard C-language library, to find other library files, to put the library files in the standard directory, the library files must follow the specific naming conventions and need to be explicitly specified on the command line;

The name of the library file always begins with Lib, and the subsequent section indicates what library it is, and the last of the file name is. A or. So.

For example: LIBM.A is a static function library;

Gcc-o Hello Hello.c/usr/lib/libm.a

Gcc-o Hello Hello.c-lm-l will first search shared library

If the library file is not in the standard directory, use-l to increase the library's search path

Gcc-o X11pro1 x1hello.c-l/usr/openwin/lib-lx11

1. Static Library:

The simplest form of a library is a set of target files that are in the ready to use state

Create and maintain your own static libraries, as long as the functions are compiled separately using the gcc-c and AR commands.

2. Shared libraries:

Static inventory saves memory by using it in each application, while the shared library is not in the application that uses it, but only when the application is running to access the shared code.

For Linux systems, the program that is responsible for loading the shared library and parsing client function references is ld.so, or ld-linux.so.2 or ld-lsb.so.1, and other locations in the search shared library can be configured in the file/etc/ld.so.conf.

3.make Tools:

The Make tool relies on a special file named Makefile or Makefile, which describes the dependencies between the various modules in the system, and when some of the files in the system change, make determines the minimum set of files that need to be recompiled, depending on the relationship.

Makefile is a text-form database file that contains rules that tell make which files to process and how to process them.

These rules are primarily what files (called target targets files) are produced from which other files (called dependency dependent files) are generated, and what commands are used to perform this process.

Depending on the information, make checks the file on the disk, and if the time at which the target file was generated or changed (the file timestamp) is at least older than one of its dependent files, make executes the corresponding command to update the target file.

A makefile file contains a series of make rules, each of which contains the following:

List of target files: List of dependent files

<TAB> Command List

The Make working directory is the current directory unless specifically specified.

To start with # as a comment line, you can use the continuation number "\" to continue a separate command into several lines.

In general, call the Make command to enter:

Make target

Target is one of the targets defined in the makefile file, and if omitted Target,make will generate the first target defined in the makefile file.

Variables in the makefile:

Defining variables: varname=string

Reference variable: ${varname}

Variables are generally Dingyi in front of makefile, and as a rule, all makefile variables should be uppercase.

In addition to user-defined variables, make allows you to use environment variables, automatic variables, and predefined variables. Because make reads the environment variables that are currently defined by the system and creates a variable with the same name as when you start.

Common pre-defined variables: [email protected], $, $<, $^

In addition the order of the rules repeats, can be omitted

4.GDB Debugging Tools:

To use the GDB debugger, you must recompile the program with the-G parameter.

C Language Development tools

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.