搭建编译环境
安装MinGW
点击http://sourceforge.net/projects/mingw/下载MinGW最新版本,运行安装程序后显示"MingGW Installation Manager"界面,选"Basic Setup",将右侧的选项全部选中,再点菜单“Installation”下的“Apply Changes”开始安装。安装完成后,到MingGW/msys/1.0/etc目录,复制fstab.sample为fstab,打开到最后几行,在“/mingw”前写入mingw的安装路径,如"d:/mingw",这样目的是为msys指定mingw。如果安装在缺省路径,那么不需要修改路径。
下载yasm.exe
到http://yasm.tortall.net/Download.html选择对应版本,下载完成后将文件名称改为yasm.exe后,放到C:\WINDOWS\system32或者C:\MinGW\bin。
下载x264最新版本
点击进入http://download.videolan.org/pub/videolan/x264/snapshots/下载页面选择最新版本下载。下载完成后,解压放到C:\MinGW\msys\1.0\home目录或者其它任意目录。
编译源代码
开始编译前,打开C:\MinGW\msys\1.0\msys.bat在文件最前面添加vs支持。
call "C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\bin\vcvars32.bat"
@echo off
rem Copyright (C): 2001, 2002, 2003, 2004, 2005 Earnie Boyd
rem mailto:earnie@users.sf.net
rem This file is part of Minimal SYStem
rem http://www.mingw.org/msys.shtml
rem
rem File: msys.bat
rem Revision: 2.4
rem Revision Date: December 8th, 2005
rem ember to set the "Start in:" field of the shortcut.
rem A value similar to C:\msys\1.0\bin is what the "Start in:" field needs
rem to represent.
rem ember value of GOTO: is used to know recursion has happened.
if "%1" == "GOTO:" goto %2
配置完成后,双击msys.bat进入编译界面,使用命令行切换到带编译源代码目录,执行
./configure --enable-shared
#./configure --enable-shared --disable-asm
make
make install
完成编译。
生成lib文件
pexports libx264-142.dll > libx264-142.def
lib /machine:ix86 /def:libx264-142.def
第一行命令,生成libx264-142.def
第二行命令,生成libx264-142.exp 和 libx264-142.lib
测试x264
#include <string>
#include "stdint.h" //如果没有,下载地址为: http://download.youkuaiyun.com/detail/evsqiezi/7014021
extern "C"
{
#include "x264.h"
#include "x264_config.h"
};
using namespace std;
int main()
{
x264_param_t param;
x264_param_default(¶m);
return 0;
}