linux上交叉编译windows的VLC

发布时间 2023-09-19 10:21:42作者: 阿风小子
1.目标
目标:在linux上交叉编译windows的VLC版本,并实现功能的裁剪
 
2.搭建环境
2.1编译环境
系统版本:UnionTech OS Desktop 20 Home
内核版本:5.10.0-amd64-desktop
VLC版本:3.0.18
预构建版本:vlc-contrib-x86_64-w64-mingw32-latest
2.2.安装工具和依赖
apt-get install gcc-mingw-w64-x86-64 g++-mingw-w64-x86-64 mingw-w64-tools
apt-get install lua5.2 lua5.2:i386 libtool automake autoconf autopoint make gettext pkg-config qt4-dev-tools qt5-default git subversion cmake cvs wine64-development-tools libwine-dev zip p7zip nsis bzip2 yasm ragel ant default-jdk protobuf-compiler dos2unix
 
/bin/bash: i686-w64-mingw32-gcc:未找到命令
apt-get install gcc-mingw-w64-i686 g++-mingw-w64-i686 mingw-w64-tools
 
2.3.获取源码
为了加快下载速度,通过gitee下载的别人fork工程,在工程tag里面下载3.0.18版本
 
2.4.准备第三方库
2.4.1.方法1:预构建(推荐)
注意:预构建的方法更快更简单,但可能需要匹配版本
 
mkdir -p contrib/win32
cd contrib/win32
 
下载http://download.videolan.org/pub/videolan/contrib/x86_64-w64-mingw32/vlc-contrib-x86_64-w64-mingw32-latest.tar.bz2,并放入contrib/win32目录
 
../bootstrap --host=x86_64-w64-mingw32
make prebuilt
 
 
2.4.2.方法2:手动构建(不建议)
注意:需要耗费大量的时间和精力,而且可能会遇见各种错误
 
apt-get install subversion yasm cvs cmake ragel autopoint
mkdir -p contrib/win32
cd contrib/win32
../bootstrap --host=x86_64-w64-mingw32
make fetch
make
 
2.5.配置编译环境
cd /home/name/vlc-3.0.18
./bootstrap
mkdir win32 && cd win32
 
export PKG_CONFIG_LIBDIR=/home/name/vlc-3.0.18/contrib/x86_64-w64-mingw32/lib/pkgconfig
 
../extras/package/win32/configure.sh --host=x86_64-w64-mingw32 --build=x86_64-pc-linux-gnu
 
../configure --host=x86_64-w64-mingw32 --build=x86_64-pc-linux-gnu --disable-chromecast  
 
3.编译VLC
make
 
4.打包VLC
make package-win-common 
输出创建名为vlc-x.x的子目录,可以直接从这个目录运行VLC
make package-win-strip
与package-win-common基本相同,但将创建“strip”的二进制文件(即最小的大小,无法供调试器使用)
make package-win32-7zip   
输出7z的压缩文件包
make package-win32-zip     
输出zip的压缩文件包
make package-win32
输出一个自动安装包。必须将NSIS安装在其默认位置才能正常工作
 
5.错误记录
5.1.错误1:configure错误
错误信息:configure: error: You need 32-bits luac when using lua from contrib.
解决方法:apt-get install lua5.2:i386
5.2.错误2:make编译错误
错误信息:stream_out/chromecast/cast_channel.pb.h:12:2: error: #error This file was generated by a newer version of protoc which is
解决方案:configure时增加选项–disable-chromecast,先关闭。网上有说法是PROTOBUF版本不一致导致,有评估该功能一般项目用不上,所以不花费精力去深究
5.3.错误3:package-win32打包错误
错误信息:make[3]: *** 没有规则可制作目标“/usr/include/wine/windows/stdole2.idl”,由“stdole2.tlb” 需求。 停止。
解决方法:安装wine(apt-get install wine),我的环境有/usr/include/wine/wine/windows/stdole2.idl没有/usr/include/wine/windows/stdole2.idl ,因此制作了超链接: ln -s /usr/include/wine/wine/windows /usr/include/wine/windows
5.4.错误4:package-win32打包错误
错误信息:/bin/bash: i686-w64-mingw32-gcc:未找到命令
解决方法:apt-get install gcc-mingw-w64-i686 g+±mingw-w64-i686 mingw-w64-tools
6.参考文档
https://wiki.videolan.org/Win32Compile/
https://wiki.videolan.org/Category:Building/