当前位置:网站首页>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
边栏推荐
- Dp83848+ network cable hot plug
- 附件一:202x年xxx攻防演习授权委托书
- How do good test / development programmers practice? Where to go
- CRS-4013: This command is not supported in a single-node configuration.
- appliedzkp zkevm(11)中的EVM Proof
- 【MATLAB】MATLAB 仿真数字基带传输系统 — 双极性基带信号(余弦滚降成形脉冲)的眼图
- 电子元器件商城与数据手册下载网站汇总
- Qt QTableView数据列宽度自适应
- LeetCode136+128+152+148
- Create ASM disk through DD
猜你喜欢
Use units of measure in your code for a better life
[cloud native] those lines of code that look awesome but have a very simple principle
Correct the classpath of your application so that it contains a single, compatible version of com. go
在代碼中使用度量單比特,從而生活更美好
Create ASM disk through DD
6-5 vulnerability exploitation SSH weak password cracking and utilization
[wechat applet] good looking carousel map component
每日刷题记录 (十二)
Unity中RampTex介绍和应用: 溶解特效优化
Dp83848+ network cable hot plug
随机推荐
【MATLAB】MATLAB 仿真 — 低通高斯白噪声
1. Mx6u-alpha development board (simulating STM32 drive development experiment)
The five pictures tell you: why is there such a big gap between people in the workplace?
Technology Management - learning / practice
What should a novice pay attention to when looking for an escort
Self sharing of a graduate
【MATLAB】MATLAB 仿真模拟调制系统 — FM 系统
CRS-4013: This command is not supported in a single-node configuration.
【Go】数据库框架gorm
Zhongke panyun-d module analysis and scoring standard
"Don't care too much about salary when looking for a job", this is the biggest lie I've ever heard
Flutter ‘/usr/lib/libswiftCore.dylib‘ (no such file)
测试 CS4344 立体声DA转换器
Operate the server remotely more gracefully: the practice of paramiko Library
The first introduction, stages and methods of defense system breakthrough from the perspective of the red team
【MATLAB】通信信号调制通用函数 — 插值函数
Cmake compilation option setting in ros2
【MATLAB】MATLAB 仿真 — 模拟调制系统 之 AM 调制过程
Kivy tutorial custom fonts (tutorial with source code)
appliedzkp zkevm(11)中的EVM Proof