在ubuntu13.10下交叉编译VLC2.1.0 win32版

本文档详细介绍了如何在Linux环境下使用Mingw-w64工具链跨平台编译VLC媒体播放器,包括获取源码、准备第三方库、配置及打包等步骤。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

官方的编译指导文档https://wiki.videolan.org/Win32Compile/ 

本人在此版本基础上增加注释,用红色或者黑底黄字标注。

Win32Compile

This page will help you to compile VLC media player for Windows.

Contents

Building Methods

If you want to build VLC from source, you have several choices:

MethodDocumentationNotes
MinGW on LinuxObtaining the toolchainPreferred method (uses cross compilation). On Windows, you should do it in a virtual machine.
MSYS+MinGW on WindowsCompile with MSysNative compilation method. MSYS is a minimal build environment to compile Unixish projects under Microsoft Windows.
Cygwin on WindowsCompile with CygwinBuild using cygwin as your compile environment. Error prone, and slow.

Obtaining the cross-compilation toolchain

Compiler and binary toolchain

1.推荐Mingw-w64

To compile VLC for Windows (32-bits or 64-bits), the Mingw-w64 toolchain is required:

  • Debian/Ubuntu: run apt-get install gcc-mingw-w64-i686 g++-mingw-w64-i686 mingw-w64-tools

(on Debian you must be on wheezy or above to find this package)

Mingw32(不推荐,除非使用Mingw-w64出问题了

Up to versions 2.0.x, VLC was compiled with the older mingw32 toolchain, which only supports 32-bits Windows. If you have problems with mingw-w64, you can try mingw32 instead:

  • Debian/Ubuntu: run apt-get install gcc-mingw32 mingw32-binutils. Note that at least version 3.17 of Mingw32 is required, which Debian does not provide. You may obtain mingw32-runtime-3.17 here.
  • Gentoo users can emerge crossdev && crossdev mingw32
  • ArchLinux users can pacman -S mingw32-gcc
  • Fedora users should read Win32Compile Under Fedora
  • Other Linux systems may attempt http://www.mingw.org/wiki/LinuxCrossMinGW

Development tools

2.You will also need: 执行 apt-get install 安装下面工具

  • lua (5.1 or 5.2)
  • all autotools: libtool, automake, autoconf, autopoint, make, gettext
  • pkg-config
  • qt4-dev-tools
  • git
  • subversion
  • cmake, cvs if you want to rebuild contribs
  • wine-dev for creating Win32 packages
  • zip [for creating .zip package], p7zip [for .7z package], nsis [for .exe auto-installer], bzip2 [for 'make prebuild]

Host triplet

A number of example commands below include the identifier of the toolchain. This value is essential: it instructs the build system to use the correct toolchain and compile the program for Windows. Without the value, the build system will perform a native compilation for Linux (or whatever your computer runs). With an incorrect value, the build will fail.

This is known as the host triplet, although it's more of a pair than a triplet in the case of Mingw. The exact value depends on your installation of the toolchain. Notably on Debian/Ubuntu, these values must be used:

  • i686-w64-mingw32 for Windows 32-bits, using the Mingw-w64 toolchain
  • x86_64-w64-mingw32 for Windows 64-bits, using the Mingw-w64 toolchain
  • i586-mingw32msvc for Windows 32-bits, using the Mingw32 toolchain

Again, you MUST substitute the value in the following command snippets.

3.Get the source code

vlc2.1.0版本代码下载  http://download.videolan.org/pub/videolan/vlc/2.1.0/vlc-2.1.0.tar.xz

如果编译最新版本,则从git获


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

See Git for more information.

4.Go into the VLC directory

$ cd vlc

5.Prepare 3rd party libraries

Before compiling VLC, you need lots of other libraries. Here is how to get them:

 $ mkdir -p contrib/win32
 $ cd contrib/win32
 $ ../bootstrap --host=i686-w64-mingw32
 $ make prebuilt

or, if you want to compile the contribs yourself and are feeling adventurous and have lots of time to burn,

如果执行上面的命令了,下面就不用执行了

 # apt-get install subversion yasm cvs cmake
 $ mkdir -p contrib/win32
 $ cd contrib/win32
 $ ../bootstrap --host=i686-w64-mingw32
 $ make fetch
 $ make

6.Linux 64-bit

补充:查看linux是32位还是64位的方法: 执行 uname -m  如果是i386到i686,那就是32位系统;如果是x86_64 ,那就是64系统。我的是32位,这步就不需要了。

If you are on Linux 64-bit, you SHOULD remove some files, or install the lib32 packages (ia32-libs, multilibs, etc...)

 $ rm -f ../i686-w64-mingw32/bin/moc ../i686-w64-mingw32/bin/uic ../i686-w64-mingw32/bin/rcc

In addition, install the qt4-tools package.

Fix your contrib path

If your Mingw prefix is not i686-w64-mingw32 (you are NOT on Debian or Ubuntu), create a symlink to contribs:

 $ ln -sf ../i686-w64-mingw32 ../i486-mingw32

7.Go Back

Go back to the VLC source directory:

 $ cd -

8.Configuring the build

Bootstrap

First, prepare the tree:

 $ ./bootstrap

9.Configure

Then you can to configure the build with the ./configure script.

Create a subfolder,Use the standard configuration:

 $ mkdir win32 && cd win32
$ ../extras/package/win32/configure.sh --host=i686-w64-mingw32
如果这步出现问题,参见最后的解决方法
执行上面命令后就不用执行下面了,到第10步。
 
 

NB: use YOUR Xcompiling prefix here, like i486-mingw32


Alternatively, you can run configure manually:

$ ../configure --host=i686-w64-mingw32

See '../configure --help' for more information.

10.Building VLC

Once configured, to build VLC, just run:

 $ make

11.Packaging VLC

Once the compilation is done, you can build self-contained VLC packages with the following make rules:

CommandDescription
make package-win-commonCreates a subdirectory named vlc-x.x.x with all the binaries. You can run VLC directly from this directory.
make package-win-stripSame as above but will create 'stripped' binaries (that is, smallest size, unusable with a debugger).
make package-win32-7zipSame as above but will package the directory in a 7z file.
make package-win32-zipSame as above but will package the directory in a zip file.
make package-win32Same as above but will also create an auto-installer package. You must have NSIS installed in its default location for this to work.

Well done—you're ready to use VLC!



执行第9步出现的问题:

1.出现error: LibVLC requires mingw-runtime version 3.15 or higher, or mingw-w64 version 3.0 or higher!

是因为mingw-64版本问题,版本必须为最新版本,更新方法是去 http://ftp.us.debian.org/debian/pool/main/m/mingw-w64/查看包,在ubuntu下可以使用一下命令安装:

wget http://ftp.us.debian.org/debian/pool/main/m/mingw-w64/mingw-w64-common_3.1.0-1_all.deb

wget http://ftp.us.debian.org/debian/pool/main/m/mingw-w64/mingw-w64-i686-dev_3.1.0-1_all.deb

wget http://ftp.us.debian.org/debian/pool/main/m/mingw-w64/mingw-w64_3.1.0-1_all.deb

sudo dpkg -i mingw-w64-common_3.1.0-1_all.deb

sudo dpkg -i mingw-w64_3.1.0-1_all.deb

sudo dpkg -i mingw-w64-i686-dev_3.1.0-1_all.deb

2.出现错误:vlc-2.1.0/contrib/i686-w64-mingw32/bin/luac: cannot execute binary file
configure: error: You need 32-bits luac when using using lua from contrib.

执行 file vlc-2.1.0/contrib/i686-w64-mingw32/bin/luac, 发现luac是64位的,这里需要一个32位的,需要执行

mv ~/tools/vlc-2.1.0/contrib/i686-w64-mingw32/bin/luac ~/tools/vlc-2.1.0/contrib/i686-w64-mingw32/bin/luac.bak

cp /usr/bin/luac5.2 ~/tools/vlc-2.1.0/contrib/i686-w64-mingw32/bin/luac




评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值