当前位置:网站首页>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


边栏推荐
- Correct the classpath of your application so that it contains a single, compatible version of com. go
- 6-4漏洞利用-SSH Banner信息获取
- Binary search tree
- Change the background color of Kivy tutorial (tutorial includes source code)
- 【MATLAB】MATLAB 仿真 — 低通高斯白噪声
- The five pictures tell you: why is there such a big gap between people in the workplace?
- 附件五:攻击过程简报.docx
- Share some of my telecommuting experience
- 【MATLAB】通信信号调制通用函数 — 低通滤波器
- Yolov6 practice: teach you to use yolov6 for object detection (with data set)
猜你喜欢

The "functional art" jointly created by Bolang and Virgil abloh in 2021 to commemorate the 100th anniversary of Bolang brand will debut during the exhibition of abloh's works in the museum

MySQL indexes and transactions

Zhengzhou zhengqingyuan Culture Communication Co., Ltd.: seven marketing skills for small enterprises

Intersection traffic priority, illustration of intersection traffic rules

Utiliser des unités de mesure dans votre code pour une vie meilleure

Use units of measure in your code for a better life

中科磐云—模块A 基础设施设置与安全加固 评分标准

中科磐云—2022广东木马信息获取解析

What is context?

Create ASM disk through DD
随机推荐
Sample template of software design document - learning / practice
Annexe VI: exposé sur les travaux de défense. Docx
【MATLAB】MATLAB 仿真数字基带传输系统 — 双极性基带信号(余弦滚降成形脉冲)的眼图
Qt QTableView数据列宽度自适应
[cloud native] those lines of code that look awesome but have a very simple principle
qt下开发mqtt的访问程序
CRS-4013: This command is not supported in a single-node configuration.
Beipiao programmer, 20K monthly salary, 15W a year, normal?
【MATLAB】通信信号调制通用函数 — 低通滤波器
抓包整理外篇fiddler———— 会话栏与过滤器
郑州正清园文化传播有限公司:针对小企业的7种营销技巧
海力士EMMC5.0及5.1系列对比详解
6-4 vulnerability exploitation SSH banner information acquisition
[Yugong series] go teaching course 001 in July 2022 - Introduction to go language premise
Self sharing of a graduate
自动化测试selenium基础篇——webdriverAPI
Download kicad on Alibaba cloud image station
记几个智能手表相关芯片 蓝牙芯片 低功耗
Maui introductory tutorial series (5.xaml and page introduction)
Flutter 调用高德地图APP实现位置搜索、路线规划、逆地理编码