其他分享
首页 > 其他分享> > ffmpeg+opencore-amr msvc编译备忘

ffmpeg+opencore-amr msvc编译备忘

作者:互联网

由于本人目前做win32桌面应用开发,需要用到ffmpeg库,而网上下载的预编译版本无法满足解码和调试的需求,所以做了自己的编译。

我采用的编译方式为 MSYS64 + MSVC(vs2019), 即在MSYS环境下使用VC的编译器来编译ffmpeg。

参考了许多文档,最重要的是官方编译文档。
链接1: https://trac.ffmpeg.org/wiki/CompilationGuide
链接2: https://www.ffmpeg.org/platform.html#Native-Windows-compilation-using-MSYS2

如果不开启第三方依赖库,官方文档非常好用。但我自己编译需要用到 libopencore-amrnb 。

编译libopencore-amrnb
这个东西需要执行configure, 没办法指定vs编译器,只能使用gcc,所以最终我用了mingw-32...(有大佬知道怎么用vs来编译它吗)
编译之前在MSYS环境中安装 mingw64 和 mingw32
pacman -S mingw-w64-i686-toolchain
pacman -S mingw-w64-x86_64-toolchain
双击打开mingw32.exe并进入opencore-amr目录,编译步骤如下:
./configure --disable-shared --prefix=/d/CommonLibraries32
make -j12
make install

编译ffmpeg
./configure --enable-libopencore-amrnb --enable-static --disable-shared --enable-gpl --enable-version3 --toolchain=msvc --extra-cflags="-I/d/ConmmonLibraries/include" --extra-ldflags="-libpath:/d/ConmmonLibraries/lib"
make -j12
make install

踩坑备忘:
注意这一段 --extra-cflags="-I/d/ConmmonLibraries/include" --extra-ldflags="-libpath:/d/ConmmonLibraries/lib"
不能用 --extra-ldflags="-L/d/ConmmonLibraries/lib" ,因为我用的msvc编译工具链,它无法识别 -L ,会导致configure失败...
不能用win风格的路径 --extra-cflags="-ID:\ConmmonLibraries\include" ,虽然是msvc编译工具链,但不知道为啥,这样会导致make时找不到头文件...
 

标签:ffmpeg,extra,--,make,备忘,编译,ConmmonLibraries,msvc
来源: https://blog.csdn.net/wx984490083/article/details/116540955