上一篇使用了Cygwin编译了VLC-2.2.1,编译过程正如官网所述,异常的慢。本篇介绍官网推荐的方法,使用Linux交叉编译VLC-2.2.1。
环境搭建
参考:Win32Compile。
源码:vlc-2.2.1.tar.xz。
库: vlc-contrib-i686-w64-mingw32-20150630.tar.bz2。
Linux:Ubuntu Desktop 15.04
本打算使用LinuxMint17.2,但这个发行版是基于Ubuntu14.04,安装mingw-tools的版本为3.1.0,会致使x265、taglib、gnutls等module编译不过,Ubuntu15.04默认安装的mingw-tools版本为3.2.0,编译时不会出问题。
安装库
本章内容需保证Ubuntu能正常联网。
12345 |
$ sudo apt-get install -y gcc-mingw-w64-i686 g++-mingw-w64-i686 mingw-w64-tools$ sudo apt-get install -y lua5.2 libtool automake autoconf autopoint make gettext$ sudo apt-get install -y qt4-dev-tools qt5-default$ sudo apt-get install -y git subversion cmake cvs wine-dev yasm$ sudo apt-get install -y zip p7zip nsis bzip2 |
安装过程中可能会出现Configuring ttf-mscorefonts-installer
的配置页面,按tab
后,一路回车即可。
执行脚本
保存如下内容到脚本01.sh
。
123456789101112131415161718192021222324252627282930 |
#!/bin/sh # This script enforces statically linking of libgcc, libstdc++-6, and libpthread,# without needing to rebuild gcc and mingw-w64 from scratch.# -static-libgcc -static-libstdc++ flags can not be used in a libtool build system,# as libtool removes flags that it doesn't understand. move() { [ -f $1 ] || return 1 mkdir -p old/ mv -v $* old/ return 0} for x in i686 x86_64do library_path_list=`$x-w64-mingw32-gcc -v /dev/null 2>&1 | grep ^LIBRARY_PATH|cut -d= -f2|sort|uniq` IFS=':' for i in $library_path_list do cd $i move libstdc++-6.dll libstdc++.dll.a libgcc_s.a libgcc_s_sjlj-1.dll && ln -s libgcc_eh.a libgcc_s.a move libpthread.dll.a libwinpthread.dll.a move libwinpthread-1.dll [ -d ../bin ] && cd ../bin && move libwinpthread-1.dll donedone exit 0 |
执行命令,将部分dll库移走备份。
1 |
$ sh 01.sh |
解压源码
执行如下命令。
12 |
$ tar xJvf vlc-2.2.1.tar.xz$ cd vlc-2.2.1/ |
准备库
执行如下命令。
12 |
$ cd contrib/$ mkdir win32; cd win32 |
1 |
$ mv ~/vlc-contrib-i686-w64-mingw32-20150630.tar.bz2 vlc-contrib-i686-w64-mingw32-latest.tar.bz2 |
编译库。
12 |
$ ../bootstrap --build=i686-w64-mingw32$ make prebuilt |
返回VLC源码根目录。
1 |
$ cd ../../ |
编译源码
首先bootstrap。
1 |
$ ./bootstrap |
手动指定pkg_config
路径。
1 |
$ export PKG_CONFIG_LIBDIR=$HOME/vlc-2.2.1/contrib/i686-w64-mingw32/lib/pkgconfig |
再执行如下命令。
12 |
$ mkdir win32; cd win32$ ../extras/package/win32/configure.sh --host=i686-w64-mingw32 |
根据CPU内核个数,执行make
命令。
1 |
make -j4 # 4核CPU |
编译速度很快,一会儿就完成了。
打包
执行如下命令。
1 |
$ make package-win-common |
执行完成后,当前目录下会生成vlc-2.2.1
目录,即为绿色版VLC。
执行测试
Ubuntu下测试。
12 |
$ cd vlc-2.2.1$ wine vlc.exe |
程序界面可正常启动,打开一个视频,音频正常,显示不正常。
将程序放置到Windows平台测试则正常。
~~ EOF ~~
时间: 2024-08-02 18:27:29