Linux gdb手把手调试debug

刚毕业那会儿不知道release和debug之间有什么区别,最近有新人问我,用了最简单的:
debug可以用gdb调试,比如某个.so的库是debug的,我们通过gdb就可以调试进入库里面,如果是release就不能,这次编译了一个debug的ffmpeg看源码。
如果想检查动态库编译的时候有没有打上-g 参数有一个好办法:
敲命令:gdb libname.so //libname.so 指对应库的名字
如果提示信息显示 Reading symbols from libname.so … done,表示编译的时候有带-g参数,反之则没有。

关于编译源码其实非常简单,一般就是config,然后make最后makeinstall
那么需要注意的就是./confiure的时候需要设置参数。
./configure --help
可以查看配置命令

下载ffmpeg后(估计还需要x264 libfdk)
debug模式
加载了x264

./configure --prefix=/home/zhen/workspace/software/thirdpartysource/libffmpeg/debug --enable-x86asm --enable-gpl --enable-nonfree  --enable-libx264 --enable-libfdk-aac --enable-libmp3lame --extra-cflags=-I/home/zhen/workspace/software/thirdpartysource/libx264/source/debug/include --extra-ldflags=-L/home/zhen/workspace/software/thirdpartysource/libx264/source/debug/lib --extra-cflags=-I/home/zhen/workspace/software/thirdpartysource/lidfdkaac/debug/include --extra-ldflags=-L/home/zhen/workspace/software/thirdpartysource/lidfdkaac/debug/lib --extra-ldflags=-L/home/zhen/workspace/software/thirdpartysource/libmp3lame/debug/lib --extra-cflags=-I/home/zhen/workspace/software/thirdpartysource/libmp3lame/debug/include --extra-cflags=-g --extra-cflags=-O0 --extra-libs=-lstdc++ --extra-cxxflags=-g --extra-cxxflags=-O0 --enable-debug=3 --disable-optimizations --disable-asm  --disable-stripping --pkg-config=true  --enable-shared  --enable-shared --enable-avresample

release 版本

./configure --prefix=/home/zhen/workspace/software/thirdpartysource/libffmpeg/release --enable-x86asm --enable-gpl --enable-nonfree  --enable-libx264 --enable-libfdk-aac --enable-libmp3lame --extra-cflags=-I/home/zhen/workspace/software/thirdpartysource/libx264/source/debug/include --extra-ldflags=-L/home/zhen/workspace/software/thirdpartysource/libx264/source/debug/lib --extra-cflags=-I/home/zhen/workspace/software/thirdpartysource/lidfdkaac/debug/include --extra-ldflags=-L/home/zhen/workspace/software/thirdpartysource/lidfdkaac/debug/lib --extra-ldflags=-L/home/zhen/workspace/software/thirdpartysource/libmp3lame/debug/lib --extra-cflags=-I/home/zhen/workspace/software/thirdpartysource/libmp3lame/debug/include  --enable-shared  --enable-shared --enable-avresample

编译后将所有库与可执行文件放到一个文件下,然后ldd查看所依赖库路径,然后通过下面这个帖子修改可执行文件依赖库路径
https://blog.csdn.net/qq1623803207/article/details/89683659
就提做法就是

cd /etc/
sudo vim ld.so.conf 

然后把你刚才文件夹路径添加进来,

sudo ldconfig

然后ldd test.exe
直到将所有依赖库拷贝进来,下来就是gdb调试了

gdb ffmpeg
b main
run
next
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值