Windows 搭建msys2+mingw32开发环境,编译安装vlc

官网的帮助文档:Win32CompileMSYS

  • 介绍
    这个就不说了
  • 安装Windows工具
    我使用了nodepad++和winrar,设置如下:
    1. 显示行尾符:视图->显示符号->显示行尾符
    2. 设置为unix行尾符:编辑->文档格式转换->转为UNIX格式2. 设置为unix行尾符:编辑->文档格式转换->转为UNIX格式
  • 安装msys2和gcc
    1. msys2的安装详见其官网,我这里碰到一个问题:在执行pacman -Su的时候提示本地签名错误
      Windows 搭建msys2+mingw32开发环境,编译安装vlc_第1张图片
      执行以下命令(我使用管理员身份执行,未验证普通用户是否可以):
      pacman-key --init
      pacman-key --populate msys2
      
    2. 我为了方便,同时进行了两者的安装,在执行pacman -S git subversion cvs automake autoconf libtool m4 make gettext pkg-config mingw-w64-i686-lua findutils mingw-w64-i686-headers yasm patch的时候,mingw-w64-i686-headers.git提示文件已存在,去掉这个仓库重新执行。
    3. 全部安装完成后,检测一下,文档提到了Restart:Exit MSys2, run autorebase.bat and re-run MSys2 from mingw32_shell.bat,我理解的是退出MSys2,运行autorebase.bat, 然后从mingw32_shell.bat再次运行MSys2,可是我特么的找不到mingw32_shell.bat啊。。。。
  • 获取vlc源码(有两点需要注意)
    1. 行尾符保证原来的就好,所以在Windows平台需要设置一下。官网使用了git config core.autocrlf=false,我这里提示无效键名,我执行了git config ---global core.autocrlf false
    2. Windows用户名中不能有空格,vlc不支持
  • 获取预编译第三方依赖库
    1. 这里碰到一个问题:which: no protoc in ......,头疼

一开始提到的官方文档有时候打不开,这里附上全文:

From VideoLAN Wiki
Jump to: navigation, search

Contents

 [hide] 
  • 1 Introduction
  • 2 Install Windows tools
    • 2.1 Text editor
    • 2.2 Unzip Utility (7-zip)
  • 3 Install MSys2 and GCC
    • 3.1 Tools
      • 3.1.1 gcc
      • 3.1.2 Restart
    • 3.2 Check GCC
  • 4 Get VLC sources
    • 4.1 Git
  • 5 Get precompiled 3rd party libraries
  • 6 Build VLC
    • 6.1 Bootstrap
    • 6.2 Configure
    • 6.3 Make (compile)
  • 7 Create packages
    • 7.1 Run VLC
    • 7.2 Create proper packages
  • 8 Troubleshooting
    • 8.1 Acknowledgements
  • 9 See also

Introduction

MSys2 is a helper environment for MinGW, the compiler chain for Windows based on GCC.

It can build VLC natively on Microsoft Windows. However, VideoLAN developers strongly recommend cross-compiling VLC from Linux, which is faster and easier. If you decide to stick to the MSYS method, you are on your own. Should you encounter any problem and ask for help, expect to be told to cross-compile.

Either way, VLC is a complex program with many dependencies, most of which are obtained/built through the command line interface. Therefore, experience with the POSIX command line (i.e. the Unix shell) is required. Time, patience and persistence are indispensable. The entire process outlined below should take at the very least 4 hours. Experience show that mistakes are common, especially with beginners, so you might need to make multiple attempts.

Install Windows tools

Text editor

To edit unix-style text documents you need a suitable editor: Notepad is not enough.

  • Use notepad2. You can set File - Line endings - Default to "Unix (LF)", but it always saves opened files in the ending style they have.
  • Or use notepad++.

Unzip Utility (7-zip)

Files to downloaded will have to be uncompressed. Some of them use Unix originated formats (.tar.gz, .tar.bz2, .tar.lzma), you will then need a versatile unzipping utility.

A recent version of 7-zip is therefore strongly advised.

Install MSys2 and GCC

Install MSys2 from http://msys2.github.io/

We recommend to use the 32bits version.

Let the default, and run the command line.

Tools

Install the autotools suite:

 pacman -S git subversion cvs automake autoconf libtool m4 make gettext pkg-config mingw-w64-i686-lua findutils  mingw-w64-i686-headers yasm patch

gcc

Download gcc from: mingw-w64.

Unzip it to C:\MSys2\

Restart

Exit MSys2, run autorebase.bat and re-run MSys2 from mingw32_shell.bat

Check GCC

Run

gcc -v

And check that it says

Thread model: win32
gcc version 4.9.2 (i686-win32-sjlj-rev0, Built by MinGW-W64 project)

Get VLC sources

Git

YOU MUST keep the native line-endings of the repo.

git config core.autocrlf=false

Clone the git repo

git clone git://git.videolan.org/vlc.git

Nota Bene: ensure your Windows user name does not contain spaces so that the cloning folder of VLC will not not have spaces in it.

Get precompiled 3rd party libraries

cd vlc/contrib
mkdir win32 && cd win32
../bootstrap --build=i686-w64-mingw32
make prebuilt

Note: check that all is well with moc -v

Build VLC

Bootstrap

In VLC root folder, do:

./bootstrap

Configure

mkdir win32
cd win32
sh ../extras/package/win32/configure.sh --host=i686-w64-mingw32 --disable-nls

Note: If you want any custom options, like "--disable-lua" or anything of that nature, you can append them.

Make (compile)

make -j4

Note: If your starts with the "u" or "x" character, change C:\MSys\1.0\home\\config.h and double all backslashes in VLC_COMPILED_BY constant.

Create packages

Run VLC

Once the compilation is done, build self-contained VLC packages with one of the following "make" commands:

make package-win-common

This will create a subdirectory named vlc-x.x.x with all the binaries with debugging symbols. You can run ./vlc.exe from there.

Create proper packages

make package-win32-zip

(Same as above but will package the directory in a zip file).

make package-win32-exe

(Same as above but will also create an auto-installer package. You will need to have NSIS installed in its default location for this to work).

Troubleshooting

See Win32CompileMSYSTroubleShooting.

Acknowledgements

This howto was re-created by Jean-Baptiste Kempf and updated in June 2009, September 2009, December 2009 and March 2010.

It was updated in June 2010 by Vicne with the help of J-b, gnosygnu and MichaelMc

It was updated in July 2012 by gnosygnu. Note that there are several new notes in Win32CompileMSYSTroubleShooting. These reflect problems that were encountered on gnosygnu's setup (Windows XP SP3). Refer to this forum thread for more information.

This howto was re-re-created by Jean-Baptiste Kempf in September 2012 and updated until 2015, with MSys2

See also

  • Win32CompileMSYSOld - deprecated documentation
Retrieved from " https://wiki.videolan.org/index.php?title=Win32CompileMSYS&oldid=31229"

你可能感兴趣的:(msys,mingw)