FFmpeg, Fplay, clion debugging environment setup

This series is based on ffmpeg4.4 source code. This article mainly explains how to build the CLion debugging environment of ffplay. ffmpeg is better debugged in Linux environment.

The system in this article is Ubuntu 18. First download FFmpeg-n4.4.1.zip. Although FFmpeg is compiled through makefile, it can still be Clion used for debugging, which is more intuitive than gdb. The latest version of CLion is relatively perfect. When I used it a few years ago, it seemed that the CMakeList file must be provided for debugging. Now only makefile files can be debugged with CLion.

The operation steps are as follows:
 

# 安装以下软件。
apt-get install diffutils make pkg-config yasm
apt-get install libsdl2-2.0
apt-get install libsdl2-dev
# 先执行 configure
./configure \
--prefix=/home/ubuntu/ffmpeg/build64/ffmepg-4.4-ubuntu \
--enable-gpl \
--enable-nonfree \
--enable-debug=3 \
--disable-optimizations \
--disable-asm \
--disable-stripping

Here are three important points to note:

1. To compile  ffplay an executable file,  sdl2 the library must be installed

2. Do not enable the dynamic library above  configure , the static library debugging will be much more convenient. ffmpeg 4.4  --enable-shared If you don't add it, you will use static library compilation. configure The rule is that static libraries and dynamic libraries can only choose one of the two.

3. There are several options in the back to turn on the debug mode, telling the compiler not to optimize the code, because sometimes the jump of the C program looks strange when the code is optimized.

Now open Clion, open the FFmpeg source directory, and click the Load Makefile Project button. As shown below:

After a while, Clion will finish loading, and there will be many makefile targets to choose from, as shown in the figure below:

Previous article < a href=" https://lin http://k.juejin.cn/?target=https%3A%2F%2Fwww.xianwaizhiyin.net%2F%3Fp%3D566 "> "ffmpeg-makefile compilation Analysis", as mentioned, the default of makefile  target is  all , so  all you can compile  ffplay an executable file by selecting it.

Makefile can have many targets, and can also compile a certain target separately. If you only need to use the dynamic library of a certain module, you can compile the target of this module separately.

Click Edit Configurations above to configure some things, as shown below:

Note that Clion's Load Makefile Project automatically adds Makefile Application, not Makefile target. So you need to compile the ffplay executable file yourself using the command line. Compile with  make -j 16 command to generate ffplay executable file. Then fill in the path of ffplay to Clion's Executable.

Now hit a breakpoint at the main() entry of the ffplay.c file, as shown below:
 

As can be seen from the above figure, the breakpoint is successful, and  avformat_open_input() the internal functions such as step into jump in can also see the data smoothly, as shown in the figure below:

In this way, using Clion greatly reduces the difficulty for newcomers to debug and understand ffplay logic. One more point, when make compiled ffpaly just now, the executable file ffmpeg was also compiled, so similarly, ffmpeg can also be debugged with breakpoints.

Original  FFmpeg, Fplay, clion debugging environment construction - Nuggets

★The business card at the end of the article can receive free audio and video development learning materials, including (FFmpeg, webRTC, rtmp, hls, rtsp, ffplay, srs) and audio and video learning roadmaps, etc.

see below!

 

Guess you like

Origin blog.csdn.net/yinshipin007/article/details/131731064
Recommended