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


边栏推荐
猜你喜欢

Annex V: briefing on the attack process docx

Technology Management - learning / practice

DCDC电源电流定义

PostgreSQL 正式超越 MySQL,这家伙也太强了吧!

抓包整理外篇fiddler———— 会话栏与过滤器

自动化测试selenium基础篇——webdriverAPI

中科磐云—D模块解析以及评分标准

郑州正清园文化传播有限公司:针对小企业的7种营销技巧

6-5 vulnerability exploitation SSH weak password cracking and utilization

技术管理 - 学习/实践
随机推荐
Formatted text of Kivy tutorial (tutorial includes source code)
1. Mx6u-alpha development board (LED drive experiment in C language version)
MySQL JDBC programming
Deep parsing structured exception handling (SEH) - by Matt Pietrek
Correct the classpath of your application so that it contains a single, compatible version of com. go
【MATLAB】MATLAB 仿真数字基带传输系统 — 数字基带传输系统
Yolov6 practice: teach you to use yolov6 for object detection (with data set)
【MATLAB】通信信号调制通用函数 — 插值函数
海力士EMMC5.0及5.1系列对比详解
Network equipment emergency response Guide
Change the background color of Kivy tutorial (tutorial includes source code)
加密和解密
Annex VI: defense work briefing docx
Annex III: scoring standard of the defender docx
Create ASM disk through DD
Niuke Xiaobai monthly race 49
Solve the problem of failed to load property source from location 'classpathapplication YML 'problem
Drozer tool
红队视角下的防御体系突破之第一篇介绍、阶段、方法
YoloV6实战:手把手教你使用Yolov6进行物体检测(附数据集)