How to Setup Code::Blocks IDE for FFmpeg development
I am digging into a project that needs to use some open source video codec library. FFmpeg is very powerful video codec library, which I decided to use in my project. I compiled and installed the ffmpeg library, then the problem comes, how to use the library in my project conviniently. My first thought is to write make file. I am not an expert in makefile things, so I changed to try to use Code::Blocks IDE, which is very easy to use. After configuring the include path and adding all the ffmpeg static library files mannully, I still can't build the project successfully.
I think I should check how FFmpeg build the library. After running make in /doc/examples directory of ffmpeg package, I get the command lines of compiling and linking these examples, I should add these settings in Code::Blocks.
In Linker settings of Code::Blocks, add "other linker options": -pthread -L/usr/local/lib -lavdevice -lavfilter -lavformat -lavcodec -ldl -lswresample -lswscale -lavutil -lrt -lmLeave compiler setting unchanged.
After changed setting, I can build a very simple test program which called ffmpeg API. but, when I tried to build ffmpeg example project imported from ffmpeq package, many warnings appeared:
...
/home/wanghaiyang/project/video_watermarking/transcoding.c:111:9: 警告: 不建议使用‘codec’(声明于 /usr/local/include/libavformat/avformat.h:893) [-Wdeprecated-declarations]
/home/wanghaiyang/project/video_watermarking/transcoding.c:112:9: 警告: 不建议使用‘codec’(声明于 /usr/local/include/libavformat/avformat.h:893) [-Wdeprecated-declarations]
/home/wanghaiyang/project/video_watermarking/transcoding.c:157:13: 警告: 不建议使用‘avcodec_copy_context’(声明于 /usr/local/include/libavcodec/avcodec.h:4240) [-Wdeprecated-declarations]
/home/wanghaiyang/project/video_watermarking/transcoding.c:157:13: 警告: 不建议使用‘codec’(声明于 /usr/local/include/libavformat/avformat.h:893) [-Wdeprecated-declarations]
/home/wanghaiyang/project/video_watermarking/transcoding.c:158:21: 警告: 不建议使用‘codec’(声明于 /usr/local/include/libavformat/avformat.h:893) [-Wdeprecated-declarations]
...
In Code::Blocks, the linker failed!
I think the problem lies in the -Wdeprecated-declarations, so I added a compiler option to bypass these warnings:
in compiler setting page, add in "other options": -Wno-deprecated-declarations
then, the project built successfully in Code:Blocks!