VLC官网:https://wiki.videolan.org/Win32Compile

周末折腾了好久,经过连续的出现问题,定位问题,解决问题,终于顺利编译通过了vlc的最新版本,中间尝试了多个版本的编译,比如vlc3.0.0,想着离2.x版本(2.x版本已经编译通过,可以参考:ubuntu平台,VLC/LibVLC交叉编译,生成win32版本,以及LibVLC增加录像接口)比较接近,应该容易编译通过,没成想也是一堆问题,其实主要还是版本导致的接口不对应问题,于是ubuntu的各种版本16.04x86,16.04x64,18.04x64等的尝试,终于看到了成功的果实,就像是中了大奖一样的心情。好吧,闲话不多说了,下面记录一下编译过程中的问题。

编译环境是在win7系统的虚拟机里面安装的ubuntu16.04x64 LTS版本,这个没什么好说的,不熟的可以自行搜索。因为vlc3.x版本需要gcc/g++支持c++11,所以gcc/g++的版本不能太低,可以通过命令gcc --version查看一下,我用的是4.9.3版本,大于4.9.0的版本都支持c++11。

官方的编译文档虽然说照着做肯定编译不过,但还是要参考一下的,最起码知道每一步该怎么去操作。

一、Mingw-w64环境

因为vlc主要用的还是32位版本,所以直接安装x86交叉编译环境:

sudo apt-get install gcc-mingw-w64-i686 g++-mingw-w64-i686 mingw-w64-tools

二、开发工具集

vlc编译过程所依赖的相关工具等,直接命令安装即可。

sudo apt-get update
sudo apt-get install lua5.2 libtool automake autoconf autopoint make gettext pkg-config
sudo apt-get install qt4-dev-tools qt5-default git subversion cmake cvs 
sudo apt-get install wine64-development-tools zip p7zip nsis bzip2
sudo apt-get install yasm ragel ant default-jdk protobuf-compiler dos2unix
sudo apt-get install gperf flex bison

安装完成后,需要确认一下gettext的版本,gettext --version查看,vlc-3.x 要求 gettext>=0.19.8,但是 ubuntu 官方源只更新到了 0.19.7,如果版本低的话,手动安装一下即可。

wget ftp://ftp.gnu.org/gnu/gettext/gettext-0.19.8.tar.xz

tar -Jxvf gettext-0.19.8.tar.xz

cd gettext-0.19.8/

./configure --prefix=/usr

sudo make && sudo make install

三、安装第三方库

首先下载vlc3.0.4源码,建议手动去官方ftp目录下载,git获取的不一定是最新版本的。

解压源码之后,进入vlc目录,开始操作:

mkdir -p contrib/win32
cd contrib/win32
../bootstrap --host=HOST-TRIPLET
make fetch
make

如果提示HOST-TRIPLET无法识别之类的问题,可以直接改成i686-w64-mingw32。

这里采用的是make fetch的方式,而没有采用make prebuilt的方式,是因为prebuilt的库文件比较旧,需要等待一点时间。

四、编译vlc

回到vlc目录,开始操作

./bootstrap
mkdir win32
cd win32
export PKG_CONFIG_LIBDIR=$HOME/vlc/contrib/i686-w64-mingw32/lib/pkgconfig
export CFLAGS="-O2"
export CXXFLAGS="-O2"
../configure --host=i686-w64-mingw32   
其中遇到了以下几个问题:

1、cp ../../contrib/tarballs/dxgi1_2.idl dxgi12 && cd dxgi12 && patch -fp1 < ../../../contrib/src/d3d11/dxgi12.patch
patching file dxgi1_2.idl
mkdir -p -- "/home/vlc/vlc/contrib/i686-w64-mingw32/include/"
i686-w64-mingw32-widl -DBOOL=WINBOOL -I/usr/include/wine/windows/ -h -o /home/vlc/vlc/contrib/i686-w64-mingw32/include/dxgi1_2.h dxgi12/dxgi1_2.idl
dxgi12/dxgi1_2.idl:43: error: syntax error, unexpected aKNOWNTYPE, expecting tIMPORT
../../contrib/src/d3d11/rules.mak:63: recipe for target '/home/vlc/vlc/contrib/i686-w64-mingw32/include/dxgi1_2.h' failed
make: *** [/home/vlc/vlc/contrib/i686-w64-mingw32/include/dxgi1_2.h] Error 1
解决方案:
sudo apt-get install wine64-development-tools 
修改 contib\src\d3d9\rules.mak 中的IDL_INC_PATH = /usr/include/wine/windows/ 为 IDL_INC_PATH = /usr/include/wine-development/windows/
修改 contrib\src\d3d11\rules.mak 中的IDL_INC_PATH = /usr/include/wine/windows/ 为 IDL_INC_PATH = /usr/include/wine-development/windows/

2、versioninfo.rc错误:

i686-w64-mingw32-windres: versioninfo.rc.in:21: syntax error 
i686-w64-mingw32-windres: preprocessing failed. 
Makefile:1224: recipe for target 'versioninfo.lo' failed 
make[2]: *** [versioninfo.lo] Error 1 
make[2]: Leaving directory '/home/d/vlc-3.0.0/contrib/win32/gcrypt/src' 
Makefile:487: recipe for target 'install-recursive' failed 
make[1]: *** [install-recursive] Error 1 
make[1]: Leaving directory '/home/d/vlc-3.0.0/contrib/win32/gcrypt' 
../../contrib/src/gcrypt/rules.mak:72: recipe for target '.gcrypt' failed 
make: *** [.gcrypt] Error 2

解决方案:
修改 contrib/win32/gcrypt/configure.ac 第42行

修改前:m4_esyscmd([git rev-parse --short HEAD | tr -d '\n\r']))
修改后:m4_esyscmd([printf %x $(wc -l < debian/changelog)]))

3、../../contrib/src/protobuf/rules.mak:24: recipe for target '.protobuf' failed
make: *** [.protobuf] Error 2
解决方案:
通过protoc --version可查看protobuf版本,需升级protobuf到3.0.1版本,这样和contribute里的版本保持一致,避免后面再次报错

https://github.com/protocolbuffers/protobuf/releases/ (此地址可能需要FQ,我会把文件放到网盘里)

configure完成后,执行sudo make,报了以下几个错误:

1、In file included from ../../modules/access/dshow/dshow.cpp:52:0:
../../modules/access/dshow/access.h:33:24: fatal error: wrl/client.h: No such file or directory
compilation terminated.

解决方案:
从 https://forum.videolan.org/viewtopic.php?f=32&t=137580&p=453684&hilit=roapi.h%3A80%3A25#p453684 下载 mingw-w64-mingw-w64
将mingw-w64-mingw-w64/mingw-w64-headers/include下的 wrl 文件夹整个拷贝到编译包的contrib/i686-w64-mingw32/include下

2、/usr/share/mingw-w64/include/roapi.h:60:33: error: ‘Windows::Foundation::Initalize’ declared as an ‘inline’ variable
     __inline HRESULT Initalize (RO_INIT_TYPE it
                                 ^
/usr/share/mingw-w64/include/roapi.h:60:33: error: ‘RO_INIT_TYPE’ was not declared in this scope
/usr/share/mingw-w64/include/roapi.h:64:7: error: expected ‘,’ or ‘;’ before ‘{’ token
     ) { return RoInitialize (it); }
       ^
/usr/share/mingw-w64/include/roapi.h: In function ‘void Windows::Foundation::Uninitialize()’:
/usr/share/mingw-w64/include/roapi.h:66:23: error: ‘RoUninitialize’ was not declared in this scope
     { RoUninitialize (); }
                       ^
/usr/share/mingw-w64/include/roapi.h: At global scope:
/usr/share/mingw-w64/include/roapi.h:74:35: error: ‘ABI::Windows::Foundation::Initialze’ declared as an ‘inline’ variable
       __inline HRESULT Initialze (RO_INIT_TYPE it
                                   ^
/usr/share/mingw-w64/include/roapi.h:74:35: error: ‘RO_INIT_TYPE’ was not declared in this scope
/usr/share/mingw-w64/include/roapi.h:78:9: error: expected ‘,’ or ‘;’ before ‘{’ token
       ) { return RoInitialize (it); }
         ^
/usr/share/mingw-w64/include/roapi.h: In function ‘void ABI::Windows::Foundation::Uninitialize()’:
/usr/share/mingw-w64/include/roapi.h:80:25: error: ‘RoUninitialize’ was not declared in this scope
       { RoUninitialize (); }
                         ^
Makefile:25261: recipe for target 'access/dshow/dshow.lo' failed
make[4]: *** [access/dshow/dshow.lo] Error 1
解决方案:
将mingw-w64-mingw-w64/mingw-w64-headers/include中的roapi.h dwrite.h  dwrite_1.h  dwrite_2.h   versionhelpers.h等文件拷贝到contrib/i686-w64-mingw32/include/,这样可以避免后面出现的许多错误

3、stream_out/chromecast/cast_channel.pb.h:12:2: error: #error This file was generated by a newer version of protoc which is
 #error This file was generated by a newer version of protoc which is
  ^
stream_out/chromecast/cast_channel.pb.h:13:2: error: #error incompatible with your Protocol Buffer headers. Please update
 #error incompatible with your Protocol Buffer headers.  Please update
  ^
stream_out/chromecast/cast_channel.pb.h:14:2: error: #error your headers.
 #error your headers.
  ^
In file included from stream_out/chromecast/cast_channel.pb.h:22:0,
                 from ../../modules/stream_out/chromecast/chromecast.h:45,
                 from ../../modules/stream_out/chromecast/cast.cpp:33:
/home/zqf/vlc/contrib/i686-w64-mingw32/include/google/protobuf/io/coded_stream.h:1362:5: warning: "_MSC_VER" is not defined [-Wundef]
 #if _MSC_VER >= 1300 && !defined(__INTEL_COMPILER)
     ^
In file included from ../../modules/stream_out/chromecast/chromecast.h:45:0,
                 from ../../modules/stream_out/chromecast/cast.cpp:33:
stream_out/chromecast/cast_channel.pb.h:25:60: fatal error: google/protobuf/generated_message_table_driven.h: No such file or directory
compilation terminated.
Makefile:25196: recipe for target 'stream_out/chromecast/libstream_out_chromecast_plugin_la-cast.lo' failed
make[4]: *** [stream_out/chromecast/libstream_out_chromecast_plugin_la-cast.lo] Error 1
解决方案:安装protobuf3.0.1版本,上面已安装的话,就应该不会报这个错误了

4、/home/zqf/vlc/contrib/i686-w64-mingw32/include/versionhelpers.h: In function ‘IsWindows8Point1OrGreater’:
/home/zqf/vlc/contrib/i686-w64-mingw32/include/versionhelpers.h:70:45: error: ‘_WIN32_WINNT_WINBLUE’ undeclared (first use in this function)
     return IsWindowsVersionOrGreater(HIBYTE(_WIN32_WINNT_WINBLUE), LOBYTE(_WIN32_WINNT_WINBLUE), 0);
                                             ^
/home/zqf/vlc/contrib/i686-w64-mingw32/include/versionhelpers.h:70:45: note: each undeclared identifier is reported only once for each function it appears in
/home/zqf/vlc/contrib/i686-w64-mingw32/include/versionhelpers.h: In function ‘IsWindowsThresholdOrGreater’:
/home/zqf/vlc/contrib/i686-w64-mingw32/include/versionhelpers.h:74:45: error: ‘_WIN32_WINNT_WINTHRESHOLD’ undeclared (first use in this function)
     return IsWindowsVersionOrGreater(HIBYTE(_WIN32_WINNT_WINTHRESHOLD), LOBYTE(_WIN32_WINNT_WINTHRESHOLD), 0);
解决方案:

修改拷贝到contrib/i686-w64-mingw32/include/下面的versionhelpers.h文件,将_WIN32_WINNT_WINBLUE和_WIN32_WINNT_WINTHRESHOLD改成_WIN32_WINNT_WIN8

引申:下面是 Windows 10 版 SDKDDKVer.h(它对每个版本的 Windows 的值进行编码)中的行:

// // _WIN32_WINNT version constants //

#define _WIN32_WINNT_NT4                     0x0400 // Windows NT 4.0 
#define _WIN32_WINNT_WIN2K                0x0500 // Windows 2000 
#define _WIN32_WINNT_WINXP                0x0501 // Windows XP 
#define _WIN32_WINNT_WS03                  0x0502 // Windows Server 2003 
#define _WIN32_WINNT_WIN6                   0x0600 // Windows Vista 
#define _WIN32_WINNT_VISTA                  0x0600 // Windows Vista 
#define _WIN32_WINNT_WS08                  0x0600 // Windows Server 2008 
#define _WIN32_WINNT_LONGHORN       0x0600 // Windows Vista 
#define _WIN32_WINNT_WIN7                   0x0601 // Windows 7 
#define _WIN32_WINNT_WIN8                   0x0602 // Windows 8 
#define _WIN32_WINNT_WINBLUE            0x0603 // Windows 8.1 
#define _WIN32_WINNT_WINTHRESHOLD           0x0A00 // Windows 10 
#define _WIN32_WINNT_WIN10                  0x0A00 // Windows 10

make完成后,进行打包生成windows相关文件的操作:

make package-win-common

第一次打包成功,无任何错误报出,第二次报出以下错误:

cp: cannot stat '../share/hrtfs': No such file or directory
Makefile:2389: recipe for target 'package-win-common' failed
make: *** [package-win-common] Error 1

解决方案:在vlc3.0.4根目录的share文件夹下面手动建一个空文件hrtfs

会在win32下面生成vlc-3.0.4文件夹,然后

cd vlc-3.0.4
find . -name "*.dll" -type f | xargs -i strip --strip-all {} 去掉调试信息

拷贝整个vlc-3.0.4文件夹到本地测试,播放文件和网络流等一切正常。

最后分享一下用到的几个文件

链接:https://pan.baidu.com/s/1Pqu5dPW_8oEKxJmR_x09Jg 
提取码:134a

18.04上的一些问题:

UBUNTU16 64位 编译VLC3.0.4 WIN32版本,遇到的问题及解决方案

上的第10条,暂时未找到解决的办法。

vlc3.0.4在ubuntu16.04x64上的交叉编译全过程记录相关推荐

  1. 使用UBUNTU16.04.1 64位编译vlc-3.0.8的WIN32版本

    vlc-3.0.8编译WIN32应用: 一.环境设置: ubuntu16 begin 开始安装:Windows 10, 64-bit  (Build 17134) 10.0.17134    VMwa ...

  2. 2021.08.28-MMsegmentation0.16.0+Cuda10.1+Ubuntu16.04+Pytorch1.8环境安装

    个人在目标检测方向的学习比较深入,但在深度学习的图像处理中,语义分割也是一个很重要的方向,所以也想一探究竟,熟悉一下基本流程和工作原理. 现打算在LINUX系统Ubuntu16.04上安装mmsegm ...

  3. VLC-3.0.0(Nightly版)在Linux和Windows下的编译步骤详解

    VLC 3.0.0 Compile vlc的编译一直是个大坑,做过音视频开发的不少人想必都踩过,开篇引用官方wiki一句话: Compiling VLC is not an easy task. 本文 ...

  4. matlab plot symbol,导入时出错matlab.引擎不导入ubuntu16.04上python3.5.2中的matplotlib。为什么?...

    我在ubuntu16.04上使用python(3.5.2)中的matlab.engine(matlabr2016b), 遵循官方指示"MATLAB API for Python". ...

  5. ubuntu16.04上搭建stm32f4开发环境

    ubuntu16.04上搭建stm32f4开发环境 工程源码的地址 https://github.com/txson/ubuntu-stm32 欢迎大家参与修改 搭建交叉编译环境 stm32 属于ar ...

  6. OpenCV 4.2.0 + opencv_contrib安装 (ubuntu16.04)

    官方发布版本: https://opencv.org/releases/ 官方教程地址: http://www.opencv.org.cn/opencvdoc/2.3.2/html/doc/tutor ...

  7. Ubuntu20.04交叉编译Vlc3.0.16,并添加录像接口

    准备工作 1.准备好ubuntu20.04的编译环境,虚拟机.云服务器都可 2.去官方网站查询一下指定编译步骤This page will help you to compile VLC media ...

  8. cuda8.0.44linux.run,ubuntu16.04+cuda8.0+cudnn6+tensorflow(gpu)1.4,一遍成功

    8种机械键盘轴体对比 本人程序员,要买一个写代码的键盘,请问红轴和茶轴怎么选? 0 python环境(ubuntu16.04自带2.7.12)0.1 查看python版本与安装路径1 2 3 4pyt ...

  9. 在Ubuntu16.04上安装CUDA

    在Ubuntu16/18上安装CUDA大体上是相同的,这里OS是Ubuntu16.04,目标CUDA版本是10.1 准备条件 在此之前Ubuntu需要安装好Nvidia对应的显卡驱动 当然,gcc编译 ...

最新文章

  1. JavaScript基础知识(函数)
  2. SQL Tips:兼顾检索速度和精确性
  3. 这个容器逃逸 exploit 获得首届年度谷歌云平台大奖10万美元
  4. LOJ P3960 列队 树状数组 vector
  5. APEX光学分析设计软件
  6. 浅谈数据挖掘与机器学习
  7. Win11录屏数据保存在哪里?Win11录屏数据保存的位置
  8. bug是什么意思详细介绍
  9. Windows10系统 无法更换锁屏图片一直转圈圈(含替换系统默认锁屏壁纸教程)异常处理
  10. 部分彩色图片处理方式的C++实现
  11. 【Pandas总结】第八节 Pandas 合并数据集_pd.merge()
  12. 微信php页面你画我猜,微信小程序你画我猜
  13. 带你熟悉 TCP/IP 协议
  14. 看过一个报道湾湾川生态靠着自动售卖机就能很赚一笔
  15. 《华为数据之道》-第8章 打造“清洁数据”的质量综合管理能力
  16. 单字双字三字_单字写法-单字怎么读-双字繁体字怎么写
  17. Count Pairs
  18. 《计算机导论》课后习题答案
  19. 百度Q2净利润同比增长45% 百家号成信息流营收源动力
  20. PMP杂谈--快速记忆ITTO

热门文章

  1. Python接口测试入门
  2. 妙用Windows神秘的类标识符,{20D04FE0-3AEA-1069-A2D8-08002B30309D}
  3. 用DensePose,教照片里的人学跳舞,系群体鬼畜 | ECCV 2018
  4. C#的一些重要知识总结
  5. 为啥你的团队总也留不住人?来看看提高员工忠诚度的3条秘诀吧!
  6. vue项目 使用 export * from 時候报错
  7. 想归隐啦——与自然生活为伴
  8. MacBook 触摸板手势突然失效的解决方案
  9. ue4 android 模拟器,UE4 真实海洋模拟器Unreal Engine Marketplace – Realistic Ocean Simulator for UE4 4.25...
  10. python 获取excel筛选文本名称