gcc compiler and GDB debugger common options

Source: Internet
Author: User
Tags gdb debugger

http://blog.csdn.net/u014328976/article/details/46745349

GCC compilers

GCC hello.c-o Hello #将hello. c compiled into a hello executable file

GCC-E hello.c-o hello.i #将hello. C converted to a preprocessed file hello.i
Gcc-s hello.c-o Hello. S #将hello. C converted to assembly file hello. S
Gcc-c hello.c-o hello.o #将hello. C converted to binary file hello.o
Gcc-i dir hello.c-o Hello #-I followed by path, specifying the dir path to find the header file

Gcc-wall Hello.c-o Hello #显示编译过程中所有的警告信息

Gcc-g hello.c-o Hello #带调试信息的程序, can be debugged with GDB

Gcc-v hello.c-o Hello #显示执行编译阶段的命令. Display compiler driver, preprocessor, compiler version number at the same time
Gcc-nostdinc-i dir hello.c-o Hello #不要在标准系统目录中寻找头文件. Search only the directory specified by the '-I ' option (and the current directory)


compile static link library
gcc-c Hello.c-o hello.o                       #先生成目标文件 . o  
GCC cxd.c-o cxd-l/root/desktop/hello.a          & nbsp     #调用自己的静态链接库

compiling dynamic-link libraries
gcc-fpic-c hello.c                              # Compiles a location-independent. o File

gcc-shared Hello.o-o hello.so #生成动态链接库

GCC cxd.c-o cxd-l/root/desktop/hello.so #调用自己的动态链接库

GDB Debugger

Note 1: The program needs to be debugged at compile time to add the-G option, the program can be debugged

NOTE 2: All of the following commands can be abbreviated initials, example: info break ==> i b except special declaration
    
#gdb Program//Enter debug mode
#list file.c:fanction//Display the Fanction function in the file.c file
#break file.c:fanction//Break a breakpoint at the Fanction function in the file.c file
#break file.c:100//hit a breakpoint on line 100th in the file.c file
#info Break//View all Breakpoints
#delete Break num//To remove breakpoints with a breakpoint number of num
#run//Start running the program
#bt//display stack of programs
#watch expr//monitor the expr variable (the value of the variable is printed each time it runs to the variable) (watch cannot be shortened)
#print expr//Print the value of the expr variable (the variable in the current run function)
#c//Continue to run the program
#next//Single Step operation
#quit//Exit Debugging

gcc compiler and GDB debugger common options

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.