mingw+vs2013 statically compile the latest ffmpeg and x264

1. Download the source code package

1、 Ffmpeg

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

2、 x264

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

or ftp://ftp.videolan.org/pub/x264/snapshots/last_x264.tar.bz2 download

2. Compilation tools

1. mingw https://sourceforge.net/projects/mingw/ install the latest version online

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

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

4. There is no http://ftp.gnome.org/pub/gnome/binaries/win32/dependencies/pkg-config-0.23-2.zip by default in pkg-config, mingw

http://ftp.gnome.org/pub/gnome/binaries/win32/glib/2.18/glib_2.18.4-1_win32.zip only need to use the libglib-2.0-0.dll file in it

Three, mingw/msys environment settings

1. Copy D:\MinGW\msys\1.0\ msys.bat to D:\MinGW\msys\1.0\ msys-vs2013.bat, open the file, and add: call "D:\Program Files (x86) \Microsoft Visual Studio 12.0\VC\bin\vcvars32.bat" save the file

2. Put yasm.exe and nasm.exe in d:/MinGW/msys/1.0/bin/

3. Extract pkg-config-0.23-2.zip and libglib-2.0-0.dll in pkg-config.exe and glib_2.18.4-1_win32.zip to d:/MinGW/msys/1.0/bin

4. Rename d:/MinGW/msys/1.0/bin/link.exe to link_renamed.exe. This step is to prevent this link.exe from conflicting with vc's link.exe. Remember to modify it after the compilation is completed.

Fourth, compile x264 1. Run 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"

5. Compile ffmpeg 1. Run msys-vs2013.bat

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

Prompt error:

The reasons for the above phenomenon are: a. x264 is not compiled with vs2013 cl. Before compiling x264 and executing ./configure, add CC=cl b. pkg-config.exe is missing in mingw

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

$ make;make install

Error:

solve:

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

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

6. Restore d:/MinGW/msys/1.0/bin/link.exe

Change d:/MinGW/msys/1.0/bin/link_renamed.exe to d:/MinGW/msys/1.0/bin/link.exe

7. Reference

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/

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324411337&siteId=291194637