Transferred from: http://www.cnblogs.com/xiongjiaji/archive/2012/06/08/2541265.html
Reference: Http://ayobamiadewole.com/Blog/Others/x264compilation.aspx
Note: After installing MinGW, add "Installation path \mingw\bin" to the PATH environment variable. Otherwise "No working C compiler found" will be/configure.
The steps are as follows:
For someone coming from a Windows background, where does virtually everything, using GUI probably with Visual studio or An equivalent IDE, compiling a program from the command line can be a daunting task.
This blog post would guide you through compiling and building the popular open source video encoding library on Windows USI ng the MinGW (minimalist GNU on Windows).
First you need to download the x264 source code from Http://x264.nl/Or if you know how to use git, you can git clone the x264 from Git://git.videolan.org/x264.git.
Then your should download MinGW from http://sourceforge.net/projects/mingw/files Download the Mingw-get-inst-20111118.exe (591.9 KB) install it and during the installation steps, select all the check boxes. (Just download it here: http://sourceforge.net/projects/mingw/)
After the installation are completed (and then add the environment variable), then from the Start button, click All Program, then click MinGW and then Cl Ick on MinGW Shell, this brings up the following window
From the Msys shell change your directory to the location where your x264 source code are, in my own case the x264 code is In the c:drive so I'll simply TypeCDc:\x264
Then type./configureand press ENTER, this screens waits for some seconds and the bring
Then you can now type Makeand press ENTER, this would bring up the window below, showing the progress of the compilation process.
After the compilation are finished, if you look into your x264 directory you'll findX264.exeFile there.
Now compiling the x264 to a dynamic link library that can is used in Visual studio takes another process entirely. Open the MinGW bash once again and change the directory to the location of the your x264 source code, just like you did Previo usly.
Then type
./configure--disable-cli--enable-shared--extra-ldflags=-wl,--output-def=libx264-120.def
or just
./configure--disable-cli--enable-shared--extra-ldflags=-wl,--output-def=libx264.def
Now in Libx264-120.def "+" is the version of the x264 you being using, you can find the version of the x264 By opening the X264.h file in your x264 source folder you'll see something like this#define X264_buildDepending on your version.
You can now type the MakeCommand and press Enter and you'll find theLibx264-120.dllIn your x264 source folder. Then renameLibx264-120.dllToLibx264.dllAnd you have the dynamic link library to work with.
If you wish to generate the Visual Studio. lib file to work with then open a Visual studio command prompt, and the Directory to the location of the x264 source.
Then run the This command
Lib/def:libx264.def
Then press ENTER
And your libx264.lib would be generated.
Compiling X264 with MinGW in Windows