mingw+vs2013静态编译最新ffmpeg与x264

一、 源码包下载

1、 Ffmpeg

$ git clone https://git.ffmpeg.org/ffmpeg.git

2、 x264

$ git clone http://git.videolan.org/git/x264.git

ftp://ftp.videolan.org/pub/x264/snapshots/last_x264.tar.bz2 下载

二、 编译工具

1、 mingw https://sourceforge.net/projects/mingw/ 在线安装最新版本

2、 yasm http://yasm.tortall.net/Download.html

3、 nasm http://www.nasm.us/pub/nasm/releasebuilds/

4、 pkg-config, mingw中默认没有 http://ftp.gnome.org/pub/gnome/binaries/win32/dependencies/pkg-config-0.23-2.zip

http://ftp.gnome.org/pub/gnome/binaries/win32/glib/2.18/glib_2.18.4-1_win32.zip只需要用到其中的libglib-2.0-0.dll文件

三、 mingw/msys环境设置

1、 复制 D:\MinGW\msys\1.0\ msys.bat 为 D:\MinGW\msys\1.0\ msys-vs2013.bat,打开文件,在最前面加上:call "D:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\bin\vcvars32.bat" 保存文件

2、 将yasm.exe与nasm.exe放置到d:/MinGW/msys/1.0/bin/中

3、 将pkg-config-0.23-2.zip解压pkg-config.exe与glib_2.18.4-1_win32.zip中的 libglib-2.0-0.dll至d:/MinGW/msys/1.0/bin中

4、 重命名 d:/MinGW/msys/1.0/bin/link.exe 为link_renamed.exe ,这一步是防止这个link.exe与vc的link.exe发生冲突,编译完成之后记得修改回来

四、 编译x264 1、 运行msys-vs2013.bat

$ cd x264
$ CC=cl ./configure --enable-static --prefix=$PWD/build_vs2013 
$ make;make install
$ export PKG_CONFIG_PATH="$PWD/build_vs2013/lib/pkgconfig"

五、 编译ffmpeg 1、 运行msys-vs2013.bat

$ cd ffmpeg
$ ./configure --toolchain=msvc --prefix=$PWD/build_vs2013 --enable-static --enable-gpl --enable-libx264 --pkg-config=pkg-config

提示错误:

出现以上现象原因有: a、 x264不是用vs2013 cl编译的,编译x264 执行./configure 前要加 CC=cl b、 mingw中缺少pkg-config.exe

$ make distclean
$ ./configure --toolchain=msvc --prefix=$PWD/build_vs2013 --enable-static --enable-gpl --enable-libx264 --pkg-config=pkg-config

$ make;make install

出错:

解决:

$ vi ffmpeg.c
在文件前面添加:
#ifndef WIN32_LEAN_AND_MEAN
 #define WIN32_LEAN_AND_MEAN
 #endif

 #include <windows.h>
 #include <winsock2.h>
保存退出
$ make;make install

六、 恢复d:/MinGW/msys/1.0/bin/link.exe

将d:/MinGW/msys/1.0/bin/link_renamed.exe改为d:/MinGW/msys/1.0/bin/link.exe

七、 参考

1、 http://blog.csdn.net/sweetloverft/article/details/38422201 2、 http://blog.csdn.net/wangjia184/article/details/7931164 3、 http://www.cnblogs.com/xylc/p/3683203.html 4、 http://www.cnblogs.com/lulu/p/5634550.html 5、 http://blog.163.com/lys_19850716/blog/static/84129044201611653736905/

猜你喜欢

转载自my.oschina.net/u/1988725/blog/1548926