In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-10 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article mainly shows you "C language C++ editor and debugging tools operation commands example analysis", the content is easy to understand, clear, hope to help you solve your doubts, the following let the editor lead you to study and learn "C language C++ editor and debugging tools operation commands sample analysis" of this article.
1. GCC compiler 1, GNU tool
Compilation tool: compiles a source program into an executable program.
Debugging tools: can debug the executive program at the source code and assembly level.
Software engineering tools: used to assist multiple developers or the management of large software projects, such as make, CVS, Subvision
Other tools: a linker for linking multiple target files into executable files, or as a tool for format conversion.
2. Introduction to GCC
The full name is GNU CC, the compilation system that conforms to the ANSI C standard in the GNU project.
Compile multiple languages such as C, C++, Object C, Java, Fortran, Pascal, Modula-3 and Ada.
GCC is a supercompiler that can compile executable programs on a variety of hardware platforms. Its execution efficiency is 20% and 30% higher than that of ordinary compilers.
A cross-platform compiler suitable for development and compilation in the embedded field
3. The version of GCC compiler
GNU Compiler Collection
C 、 C++ 、 Objective-C 、 Fortran,Java 、 Ada
Http://gcc.gnu.org
4. Interpretation of suffixes supported by gcc
C-C original program
.C / .cc / .cxx-C++ original program
M-Objective-C original program
.I-C original program that has been preprocessed
.II-C++ original program that has been preprocessed
.s / .s-the original program of assembly language
.h-preprocessing file (header file)
.o-Target file
.a / .so-compiled library file
5. The main components of the compiler
Parser: the parser converts source language program code into assembly language. Because you want to convert from one format to another (C to assembly), the parser needs to know the assembly language of the target machine.
Assembler: the assembler converts assembly language code into CPU executable bytecode.
Linker: the linker combines individual object files generated by the assembler into executable applications. The linker needs to know this target format in order to work.
Standard C library: the core C functions are provided by a major C library. If a function from the C library is used in the application, the library generates the final executable through the linker and the source code connection.
6. Basic usage and options of GCC
The most basic use of Gcc: gcc [options] [filenames]
-c, only compiles, does not connect to become executable files, the compiler only from the input .c and other source files to generate .o-suffixed object files, usually used to compile subroutine files that do not contain the main program.
-o output filename, make sure that the name of the output file is output filename, and this name cannot have the same name as the source file. If this option is not given, gcc gives the default executable file a.out
-g to generate the necessary symbolic information for the symbolic debugging tool (GNU's gdb). To debug the source code, we must add this option.
-0, optimize the compilation and connection of the program, and adopt this option, the whole source code will be optimized in the process of compilation and connection, so that the executable file will be executed more efficiently, but, the speed of compilation and connection will be slower accordingly.
-02, better than-0 to optimize the compilation and connection, of course, the whole compilation and connection process will be slower.
-l dirname, which adds the directory indicated by dirname to the list of program header files, is a parameter used during precompilation.
-L dirname, which adds the directory indicated by dirname to the directory list of the program function archive file, is a parameter used in the linking process.
7. The error types and countermeasures of GCC.
8. GCC compilation process
1. Preprocessing: processing statements that begin with "#" to generate a file with the suffix ".I".
Gcc-E test.c-o test-Wall-lm
2. Compile: generate "*. S" assembly files from "*. I" files according to different processors.
Gcc-S test.i-o test.s
3. Assembler processing: assembler code is not directly recognized by the computer, to be processed by the assembler to generate "* .o" object file, you can use the file command to view the file information.
Gcc-c test.s-o test.o
4, link: multiple "* .c" files will generate multiple "* .o" files, you need to use a linker to link each "* .o" file, the standard C library is automatically linked by default.
Gcc test.o-o test-lm
# include # include # define N 10#define _ DEBUG_int main (int argc,const char * argv []) {double m = 615 sqrt n; m + = N; n = sqrt (m); # ifdef _ DEBUG_ printf ("debug:m=%lf n=%lf\ n", m ·n); # else printf ("release:m=%lf n=%lf\ n", m ·n); # endif return 0;}
Conditional compilation
1. According to whether the macro is defined or not
# ifdef... # else... # endif
2. The value defined by the macro
# define DEFINE 1
# if DEFINE... # else... # endif
2. GDB debugging tools 1. Gdb debugging process:
First use gcc to compile the * .c file, be sure to add the option-g
1. Gcc-g *. C-o * *
2 、 gdb gcc
2. After entering the code debugging mode
(gdb) l-view files
(gdb) b 6-set breakpoint
(gdb) del 1-delete the first breakpoint
(gdb) info b-check breakpoints
(gdb) r-run the code
(gdb) p n-View variable values
(gdb) n (gdb) s-single step run n: do not enter the subfunction when running the main program, s: enter the subfunction when the main function is run
(gdb) c-resume the program running-run directly to the next breakpoint
(gdb) help [command]-help
(gdb) Q-exit
(gdb) set args-used to adjust command line parameters
The above is all the contents of this article "sample Analysis of operating commands of C++ Editor and debugging tools in C language". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.