使用Xcode断点调试ffmpeg

最近想在xcode断点调试ffmpeg,以深入学习ffmpeg源码。一开始参考了https://www.jianshu.com/p/226c19aa6e42。但发现只能断点调试,点击源码方法无法实现自动跳转,跟踪起来十分不便。于是决定暴力的创建xcode工程,添加ffmpeg所有源码来实现真正的即可加断点调试又可以跟踪跳转代码的xcode工程。主要思路是先configure生成config.h,依靠config.h实现在xcode里的配置。configure如下:

./configure --enable-debug --disable-doc --enable-ffplay --enable-sdl --disable-audiotoolbox \
 --disable-cuda            --disable-cuvid   --disable-d3d11va      --disable-dxva2  \
      --disable-libmfx      --disable-libnpp         --disable-mmal  --disable-nvenc     \
      --disable-omx     --disable-omx-rpi        --disable-vaapi        --disable-vda      \
--disable-vdpau  --disable-videotoolbox    --disable-asm \


这里为方便调试,configure选项没有加入汇编优化和硬件加速,只configure获取config.h就好,make交给xcode实现。

然后把ffmpe所有源码添加进去。然后根据配置删除不需要加入编译的代码,如汇编和硬件加速的代码。技巧是make一下看那些文件生成了.o中间文件,没生成.o的都不需要加入xcode里编译。整个过程遇到很多编译错误,只能根据错误提示一点点修改:此处略去10000字(添加移除c文件,添加头文件,添加链接库,还要修改部分文件....)。花了一天多的时间总算完成,ffmpeg 和ffplay都可执行。已上传github,需要的自提:https://github.com/badousuan/ffmpeg-xcode.git,ffmpeg 版本是最新的3.4.1.

唉,真是作死,非要整这玩意。附上一些编译过程中能记得起来的error,做个备忘,万一还有下次呢


./configure --enable-debug --disable-doc --enable-ffplay --enable-sdl --disable-audiotoolbox \
 --disable-cuda            --disable-cuvid   --disable-d3d11va      --disable-dxva2  \
      --disable-libmfx      --disable-libnpp         --disable-mmal  --disable-nvenc     \
      --disable-omx     --disable-omx-rpi        --disable-vaapi        --disable-vda      \
--disable-vdpau  --disable-videotoolbox    --disable-asm \

cp config.h libavfilter/
cp config.h fftools/
cp config.h libswresample/
cp config.h libswscale/
cp config.h libavformat/
cp config.h libavutil/
cp config.h libavcodec/
cp config.h libavdevice/
config文件,不进行汇编优化和硬件加速,将config.h拷贝到个子库


make ffmpeg 看那些文件又生成.o文件,生成.o的才是要加入编译


Type 'struct Point' has incompatible definitions in different translation units:typedef struct Point{...} Point--->typedef struct{...} Point


"ff_ctz", referenced from:位于libavutil/intmath.c,在其他库里pch #include "../libavutil/intmath.h"


NULL_IF_CONFIG_SMALL 在其他库里pch #include "../libavutil/internal.h"


undeclared identifier 'ff_log2_tab' 找不到--->在相应文件添加extern const uint8_t ff_log2_tab[256];


bz2... icv...找不到"_BZ2_bzDecompressInit", referenced from:
_matroska_decode_buffer in libavformat.a(matroskadec.o)
"_iconv", referenced from:libbz2和libiconv的链接库:添加libbz2.dylib,libiconv.dylib两个文件



"_avpriv_aac_parse_header", referenced from: libavcodec.o等,查看avpriv_aac_parse_header函数在哪个文件定义,再看这个文件是否被编译


A referenced from:B问题都看B在那个文件F引用了A,F未被加入编译则加入编译,已加入编译则A为系统库,未被-l


'SDL.h' file not found、 "_SDL_CreateTexture", referenced from: _sdl2_write_header in libavdevice.a(sdl2.o):加入SDL2链接库,并设置头文件和lib的路径


ARC forbids Objective-C objects in struct:build setting Object-c auto reference counting设为no


Initializer element is not a compile-time constant???忘了


../libavutil/libm.h:62: error: static declaration of 'lrint' follows non-static declaration  
../libavutil/libm.h:69: error: static declaration of 'lrintf' follows non-static declaration  
../libavutil/libm.h:76: error: static declaration of 'round' follows non-static declaration  
../libavutil/libm.h:83: error: static declaration of 'roundf' follows non-static declaration----->没拷贝config.h


int attribute_align_arg avcodec_open Expected ; after top level declarator, error in xcode:需要pch #include "../libavutil/internal.h"



  • 2
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值