msys2编译libx264库

时间已经是2018年了,又一次编译libx264的32/64位的库,写个笔记吧。同时也发在了新浪博客。
这次使用msys2原始安装包。下载地址:https://sourceforge.net/projects/msys2/

(1)双击安装msys2-x86_64-20161025.exe,默认安装路径
C:\msys64\mingw32.exe或mingw64.exe,分别是mingw的32和64位编译环境

(2)编译64位libx264库,就打开mingw64.exe安装gcc等基本的编译工具,
 参考链接
https://stackoverflow.com/questions/30069830/how-to-install-mingw-w64-and-msys2


MSYS has not been updated a long time, MSYS2 is more active, you can download from MSYS2, it has both mingw and cygwin fork package.

To install the MinGW toolchain (Reference):

1.      Open MSYS2 shell from start menu

2.      Run pacman -Sy pacman to update the package database

3.      Re-open the shell, run pacman -Syu to update the package database and core system packages

4.      Re-open the shell, run pacman -Su to update the rest

5.      (Reference)

·         For 32-bits, run pacman -S mingw-w64-i686-toolchain

·         For 64 bits, run pacman -S mingw-w64-x86_64-toolchain

6.      Select which package to install, default is all

7.      You may also need make, run pacman -S make


 

没有安装编译环境之前, gcc -v  会提示找不到gcc,
安装工具链之后,gcc -v会显示gcc版本号

(3)解决libx264所需的依赖库,譬如缺少nasm

pacman -S nasm

(4)下载libx264源码,解压缩,进入x264源码的目录下
官方网站
https://www.videolan.org/developers/x264.html

git clone http://git.videolan.org/git/x264.git
(5)编译libx264,编译出.a并能够转为.lib,参考链接

http://www.ayobamiadewole.com/Blog/Others/x264compilation.aspx

Now compiling the x264 into a dynamic link library that can be used in Visual studio takes another process entirely. Open the MinGW bash once again and change the directory to the location of your x264 source code, just like you did previously. 
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 “120” is the version of the x264 you are using, you can find the version of the x264 you are using by opening the x264.h file in your x264 source folder you will see something like this #define X264_BUILD 120 depending on your version.

You can now type the make command and press enter and you will find the libx264-120.dll in your x264 source folder. Then rename libx264-120.dll to libx264.dll and you have you 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 change the directory to the location of the x264 source . 
Then run this command
 LIB /DEF:libx264.def  /Machine:x64
Then press enter 


你可能感兴趣的:(ffmpeg)