当前位置:网站首页>Simple g++ and GDB debugging
Simple g++ and GDB debugging
2022-07-04 04:57:00 【Lzg_ na】
List of articles
1. The build process
| step | effect | command |
|---|---|---|
| Preprocessing | Macro expansion , The header file contains | g++ -E test.cpp -o test.i |
| compile | Generate assembly statement code | g++ -S test.i -o test.s |
| assembly | Generate machine language code | g++ -c test.s -o test.o |
| link | Generate executable files | g++ test.o -o test.exe |
2. g++ Important parameter
| Parameters | effect | command |
|---|---|---|
| -g | Can be gdb debugging | g++ -g test.cpp -o test.exe |
| -O[n] | Code optimization | g++ -O2 test.cpp -o test.exe |
-l | Specify dynamic and static library files | g++ -lglog test.cpp -o test.exe |
| -L | Specify the dynamic and static library file path | g++ -L/home/lzg -lmytest test.cpp -o test.exe |
| -Wall | Print alarm information | g++ -Wall test.cpp -o test.exe |
| -w | Turn off the alarm message | g++ -w test.cpp -o test.exe |
| -std=c++11 | Specify compilation criteria | g++ -std=c++11 test.cpp -o test.exe |
| -D | Specify macro name | g++ -DV5PLAT test.cpp -o test.exe |
-I | Appoint include File path | g++ -DV5PLAT test.cpp -o test.exe |
3、 Generate library files

3.1 Static library
1. Generate binaries
g++ -c swap.cpp -o swap.o -I../include
2. Archive as static library
ar rs libSwap.a swap.o
3. Compile with static library main
g++ main.cpp -lSwap -Lsrc -Iinclued -o main.exe
4. Run the executable
./main.exe
To be sure :
1、-Lsrc Is to execute the path of the static library file , Instead of specifying the source code path
2、-lSwap Do not link static libraries with complete static library names (lib*.a) Write it in
3.2 Dynamic library
1. Generate binaries
g++ -c swap.cpp -I../include -fPIC -shared -o libSwap.so
2. Archive as static library
ar rs libSwap.a swap.o
3. Compile with static library main
g++ main.cpp -lSwap -Lsrc -Iinclued -o main.exe
4. Run the executable
LD_LIBRARY_PATH=src ./main.exe
You need to indicate the path of the dynamic library .
4. gdb debugging
gdb Debugging needs to be added at compile time -g Parameters , Ability to support gdb debugging .
gdb file
ctrl -x ctrl -a
or :
gdbtui file


边栏推荐
- Yolov6 practice: teach you to use yolov6 for object detection (with data set)
- Annex 4: scoring criteria of the attacker docx
- Technology Management - learning / practice
- C language one-way linked list exercise
- 附件五:攻击过程简报.docx
- Flutter 调用高德地图APP实现位置搜索、路线规划、逆地理编码
- Definition of DCDC power supply current
- @Feignclient comments and parameters
- QT qtableview data column width adaptation
- 附件二:攻防演练保密协议.docx
猜你喜欢

RPC - grpc simple demo - learn / practice

qt下开发mqtt的访问程序

Zhongke panyun-d module analysis and scoring standard

RAC delete damaged disk group

电子元器件商城与数据手册下载网站汇总

VSCode的有用插件
![[cloud native] those lines of code that look awesome but have a very simple principle](/img/6d/220c51a643263f431fb57c97c4b8ff.png)
[cloud native] those lines of code that look awesome but have a very simple principle

DCDC电源电流定义

Introduction and application of rampax in unity: optimization of dissolution effect

MySQL indexes and transactions
随机推荐
【MATLAB】通信信号调制通用函数 — 低通滤波器
GUI application: socket network chat room
附件二:攻防演练保密协议.docx
【MATLAB】MATLAB 仿真模拟调制系统 — VSB 系统
由于使用flash存放参数时,擦除掉了flash的代码区导致进入硬件错误中断
Niuke Xiaobai monthly race 49
《Cross-view Transformers for real-time Map-view Semantic Segmentation》论文笔记
Self sharing of a graduate
YoloV6实战:手把手教你使用Yolov6进行物体检测(附数据集)
郑州正清园文化传播有限公司:针对小企业的7种营销技巧
Yolov6 practice: teach you to use yolov6 for object detection (with data set)
Asahi Kasei participated in the 5th China International Import Expo (5th ciie) for the first time
【MATLAB】MATLAB 仿真数字基带传输系统 — 数字基带传输系统
PostgreSQL 正式超越 MySQL,这家伙也太强了吧!
Error response from daemon: You cannot remove a running container 8d6f0d2850250627cd6c2acb2497002fc3
6-4漏洞利用-SSH Banner信息获取
RPC - gRPC简单的demo - 学习/实践
Kivy tutorial 07 component and attribute binding implementation button button click to modify the label component (tutorial includes source code)
Dp83848+ network cable hot plug
Wobo Union ended its strategic evaluation and decided to retain Bozi's business with excellent performance