编译环境:
1、win7+vmware15+Ubuntu 18 64bit虚拟系统(16也可以)
2、gcc 7.4 (大于6即可)
3、mingw-w64 5.3.0,及其相关联的x86-64的tool,也应该是同类的版本【最关键-切记】
4、jdk1.8 231
5、vlc 3.0.7.1 (github选择这个tag进行下载)——其他版本本人编译用同样的环境试过,均编译失败
6、git最新版
7、其他完全按照官方https://wiki.videolan.org/Win32Compile/ 进行处理
8、时间:2019.10.22
9、脚本看本文后面的自动化shell脚本
结果:禁用了QT等,最后编译成功,vlc.exe播放正常,编译用时8小时,总共折腾时间:15天,共尝试编译次数:20+次,连续开机最长3天,产生文件大小,至少有150G,安装了3个Ubuntu虚拟机。
一句话总结:vlc编译使用了数百个lib或tool,错综复杂,导致编译对tooltrain环境要求很高,往往一个tool导致失败,有一些没有明确提示,可谓西天取经72难。
谨以此分享给各位,希望大家少走弯路,有错误能查到一些相关信息,不要太寂寞(我编译的过程,在csdn找到一个shell脚本(shell by yangxun),很有用,再次感谢,节省了大量输入工作。其他有部分可以查到,但几乎没有一个有用的,很多网上都查不到任何信息)。
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
下面是编译过程使用的一些零星记录,包括一些重要问题的处理方法,仅供参考:
1、git clone https://github.com/videolan/vlc-3.0.git
记得不要用sudo,否则会有问题
git remote add origin https://github.com/videolan/vlc.git
2、装mingw-w64
http://mirrors.163.com/ubuntu/pool/universe/m/mingw-w64/mingw-w64_5.0.3-1_all.deb
装完这个之后,有错误提示,也不用理会
执行:
sudo apt-get -f install
会把依赖全部自动装上
安装其他:
apt-get install gcc-mingw-w64-x86-64 g++-mingw-w64-x86-64 mingw-w64-tools
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 libwine-dev zip p7zip nsis bzip2
sudo apt-get install yasm ragel ant default-jdk protobuf-compiler dos2unix
sudo apt-get install subversion yasm cvs cmake ragel autopoint
######################后记
为了安装指定的版本,你需要使用下列指令
sudo apt-get install gcc-mingw-w64-base=5.3.1-8ubuntu3+17
sudo apt-get install gcc-mingw-w64-x86-64=5.3.1-8ubuntu3+17
sudo apt-get install g++-mingw-w64-x86-64=5.3.1-8ubuntu3+17
sudo apt-get install mingw-w64-tools=5.0.3-1
正常安装好,/usr/lib/gcc/x86_64-w64-mingw32/会看到5.x版本的文件夹
而且这些版本在你的Ubuntu库中不一定有,你需要添加源:
sudo gedit /etc/apt/sources.list
在打开单位文件的最后添加:
deb http://mirrors.163.com/ubuntu/ xenial main restricted universe multiverse
deb http://mirrors.163.com/ubuntu/ xenial-security main restricted universe multiverse
deb http://mirrors.163.com/ubuntu/ xenial-updates main restricted universe multiverse
deb http://mirrors.163.com/ubuntu/ xenial-proposed main restricted universe multiverse
deb http://mirrors.163.com/ubuntu/ xenial-backports main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ xenial main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ xenial-security main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ xenial-updates main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ xenial-proposed main restricted universe multiverse
下面的源也可以加入:
#中科大源
deb https://mirrors.ustc.edu.cn/ubuntu/ bionic main restricted universe multiverse
deb https://mirrors.ustc.edu.cn/ubuntu/ bionic-updates main restricted universe multiverse
deb https://mirrors.ustc.edu.cn/ubuntu/ bionic-backports main restricted universe multiverse
deb https://mirrors.ustc.edu.cn/ubuntu/ bionic-security main restricted universe multiverse
deb https://mirrors.ustc.edu.cn/ubuntu/ bionic-proposed main restricted universe multiverse
deb-src https://mirrors.ustc.edu.cn/ubuntu/ bionic main restricted universe multiverse
deb-src https://mirrors.ustc.edu.cn/ubuntu/ bionic-updates main restricted universe multiverse
deb-src https://mirrors.ustc.edu.cn/ubuntu/ bionic-backports main restricted universe multiverse
deb-src https://mirrors.ustc.edu.cn/ubuntu/ bionic-security main restricted universe multiverse
deb-src https://mirrors.ustc.edu.cn/ubuntu/ bionic-proposed main restricted universe multiverse
#阿里云源
deb http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse
#清华源
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-updates main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-backports main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-security main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-proposed main restricted universe multiverse
deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic main restricted universe multiverse
deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-updates main restricted universe multiverse
deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-backports main restricted universe multiverse
deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-security main restricted universe multiverse
deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-proposed main restricted universe multiverse
对于上述的源,一定要知道:bionic 指的是Ubuntu特定版本18版本,如果你需要的版本在其他Ubuntu版本,你需要强制改变这个名字,比如我本人在bionic版本的Ubuntu中加了xenial源,就是为了解决特定tooltrain的安装问题,否则你的apt-get install xxx==xxxversion的命令会提示找不到这个tool的版本。
但这个配置上去,会造成混乱,把各个版本混杂在一起了,有点铤而走险的意思了。
添加源后,不会马上生效,你还需要:sudo apt-get install update,才会更新这些源列表到本地(这个可能会导致软件自动更新,从而覆盖了正确版本的mingw-w64,每次开机都会这样,可以设置不要自动更新)
######################
3、扩展磁盘
ubuntu的磁盘扩展比较麻烦:
要先在vmware扩展磁盘大小,然后还需要在Ubuntu里面做如下工作:
安装运行gparted
sudo apt-get install gparted
sudo gparted
然后禁用交换分区(swap of),然后删除扩展分区,如果不能删除,请先删除swap分区后再操作。
完了之后就可以resize 主磁盘大小了,把主分区大小调整到总大小-2G的空间,确定后剩余2G在建立扩展分区,然后再建立swap分区即可
请参照:https://blog.csdn.net/daemon_2017/article/details/80660372
扩展后,还需要修改uuid
sudo blkid
找到第二个uuid,复制
然后修改/ets/fstab文件中对红线部分进行修改,注意,必须是swap 分区
/ets/fstab 需要先赋予权限
准备自动化脚本
sudo sh compile-script-win.sh -a x86_64-w64-mingw32
修改main.mak:
download_pkg = ( $(call download,$(1)) ||
$(call download,$(CONTRIB_VIDEOLAN)/$(2)/$(lastword $(subst /, ,$(@)))) && echo "Please upload this package $(lastword $(subst /, ,$(@))) to our FTP" )
//连续10秒速度低于1即算失败,连接等待时间不超过10秒
curl -Y 1 -y 10 --retry 3 --connect-timeout 10 --keepalive-time 20 --max-time 1800 -f -L -- "http://downloads.videolan.org/pub/contrib/theora/libtheora-1.1.1.tar2.xz" > "mytest.deb"
4、安装Ubuntu18clean后重新编译
5、重新编译出错
6、clean后重新编译 缺少gperf,幸好可以apt-get
7、到了编译vlc内部代码的时候,最后居然发现缺少yacc sudo apt-get install -y byacc,安全过关
8、下列命令方法,可以使得Ubuntu下安装多个gcc,并使其一个在系统范围内生效,太帅气了:
sudo apt install software-properties-common
sudo add-apt-repository ppa:ubuntu-toolchain-r/test
这个是安装gcc8
sudo apt install gcc-8 g++-8
但是安装后测试版本仍然是7.0,原因是8.0没有配置为默认编译器,需要通过下列方法配置:
#这句slave有问题,换成后面两句即可
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-8 80 --slave /usr/bin/g++ g++ /usr/bin/g++-8
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-8 80
sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-8 80
//soft link cc to gcc-8,mean cc==gcc-8 这个也必要,很多地方不使用gcc而是直接使用cc命令,要创建一个cc软连接指向gcc-8
//解决../bootstrap: cc: not found
sudo update-alternatives --install /usr/bin/cc cc /usr/bin/gcc-8 80
sudo update-alternatives --install /usr/bin/YACC YACC /usr/bin/byacc 80
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-7 100
sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-7 100
sudo update-alternatives --install /usr/bin/cc cc /usr/bin/gcc-7 100
之后还提示BUILDCC没有定义,可以执行export BUILDCC=/usr/bin/gcc ,但不可以直接修改configure文件,该文件总是会被覆盖,可以命令行,也可以修改
9局部重新编译的方法:
编译中间结果都在:
/home/js/vlcca/vlcgithubandroid/vlcwin64/vlc30/vlc/contrib/win64/下面,这个可以复制,然后在编译的时候先clean,再覆盖,应该可以节省很多时间
10、一觉醒来发现Unknown option "--ranlib=x86_64-w64-mingw32-ranlib"
这个麻烦,搞了半小时,发现没有什么问题。x86_64-w64-mingw32-ranlib 这个lib软件是有安装的。
后来把postproc-3b7053f46dbfe4662063345245cb00b6acbbe969.tar.xz(ctrl+f搜索到)这个gz文件删除,果然系统开始重新下载该文件,之后顺利过关
10、永远不要在一个目录里面编译不同版本的,包括覆盖,都不行###############
重新github下载最新新的3.x版本,重新建立目录,只复制tarballs目录过来,全新编译
发现少了很多tool没有装,但是在3.0那边根本没有提示,说明已经编译好的中间结果,不会再重新编译,哪怕你覆盖了最新版本的程序都不会变化。
11发现protobuf(protoc)系统版本为3.10.0而要求版本为3.1.0,出现错误终止
我修改make强制让3.10.0通过。后果会怎样,未可知
/home/js/vlcca/winV3/contrib/src/protobuf/rules.mak:17中,修改如下
#ifneq ($(PROTOBUF_VERSION),$(SYS_PROTOC_VERSION))
ifneq ($(PROTOBUF_VERSION),$(PROTOBUF_VERSION))
我赌高版本应该可以满足低版本的
##################后记:这个真可以,没什么问题,你修改掉版本的限制提示也可以通过,不一定要完全匹配。
12、configure: error: Cannot find native C99 compiler: please define BUILDCC.
在mycompile.sh 或后来的list.sh文件开头增加
export BUILDCC=/usr/bin/gcc
13、碰到下载的git master的zip文件直接解压没有git仓库的问题,导致找不到version.txt文件
git init
git remote add origin https://github.com/videolan/vlc.git
git add .
git pull
git remote update
git commit -m "abctest"
git branch --set-upstream-to=origin/master dev
#################后记:上述init,pull过程实际上是从0开始下载了。但后来发现有更简单的方法:这个文件version.txt你可以随便找一个copy都可以,无需重建git仓库
最稳妥的做法是:先git clone https://github.com/videolan/vlc-3.0.git 然后会创建一个目录,里面会生成.git隐藏文件夹(Ubuntu用ctrl+h可以查看到)
你需要复制一个该文件,然后通过ctrl+z无条件终止git clone的执行,因为这个clone要下载240mb左右的文件,断断续续,经常eof失败,至少需要1小时,生命浪费不起啊。
此时最好关闭git clone的终端窗口,你会看到.git文件随之消失。然后你就可以把你复制的那个改为原名即可。
这样这个目录仍然是合法的git仓库,你只需要到github.com网站下载对应版本的zip文件下来(大概40mb,下载速度稳定,大概只需要5分钟即可),解压到你刚刚git clone的那个目录。
这样就重建完成了。
但开始如果没有git clone得到.git目录的话,你只能按照init,add,pull等方式慢慢处理了。
##########################
14、仍然碰到collect2: error: ld returned 1 exit status的问题
../../modules/access/dshow/crossbar.cpp:204:29: note: ‘outputPinIndex’ was declared here
LONG inputPinIndex = 0, outputPinIndex;
^~~~~~~~~~~~~~
CXXLD libdshow_plugin.la
/usr/lib/gcc/x86_64-w64-mingw32/7.3-win32/libstdc++.a(cow-stdexcept.o):(.text$_Z35_txnal_cow_string_C1_for_exceptionsPvPKcS_+0x2c): relocation truncated to fit: R_X86_64_PC32 against undefined symbol `_ITM_RU1'
/usr/lib/gcc/x86_64-w64-mingw32/7.3-win32/libstdc++.a(cow-stdexcept.o):(.text$_Z35_txnal_cow_string_C1_for_exceptionsPvPKcS_+0x39): relocation truncated to fit: R_X86_64_PC32 against undefined symbol `transaction clone for operator new[](unsigned long long)'
/usr/lib/gcc/x86_64-w64-mingw32/7.3-win32/libstdc++.a(cow-stdexcept.o):(.text$_Z35_txnal_cow_string_C1_for_exceptionsPvPKcS_+0x5d): relocation truncated to fit: R_X86_64_PC32 against undefined symbol `_ITM_memcpyRtWn'
/usr/lib/gcc/x86_64-w64-mingw32/7.3-win32/libstdc++.a(cow-stdexcept.o):(.text$_Z23_txnal_cow_string_c_strPKv+0x1): relocation truncated to fit: R_X86_64_PC32 against undefined symbol `_ITM_RU8'
/usr/lib/gcc/x86_64-w64-mingw32/7.3-win32/libstdc++.a(cow-stdexcept.o):(.text$_Z23_txnal_sso_string_c_strPKv+0x1): relocation truncated to fit: R_X86_64_PC32 against undefined symbol `_ITM_RU8'
/usr/lib/gcc/x86_64-w64-mingw32/7.3-win32/libstdc++.a(cow-stdexcept.o):(.text$_Z20_txnal_cow_string_D1Pv+0x5): relocation truncated to fit: R_X86_64_PC32 against undefined symbol `_ITM_RU8'
/usr/lib/gcc/x86_64-w64-mingw32/7.3-win32/libstdc++.a(cow-stdexcept.o):(.text$_Z20_txnal_cow_string_D1Pv+0x1e): relocation truncated to fit: R_X86_64_PC32 against undefined symbol `_ITM_addUserCommitAction'
/usr/lib/gcc/x86_64-w64-mingw32/7.3-win32/libstdc++.a(cow-stdexcept.o):(.text$_ZGTtNSt11logic_errorC1EPKc+0x2e): relocation truncated to fit: R_X86_64_PC32 against undefined symbol `_ITM_memcpyRnWt'
/usr/lib/gcc/x86_64-w64-mingw32/7.3-win32/libstdc++.a(cow-stdexcept.o):(.text$_ZGTtNSt11logic_errorC1ERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE+0x2e): relocation truncated to fit: R_X86_64_PC32 against undefined symbol `_ITM_memcpyRnWt'
/usr/lib/gcc/x86_64-w64-mingw32/7.3-win32/libstdc++.a(cow-stdexcept.o):(.text$_ZGTtNSt11logic_errorC1ERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE+0x36): relocation truncated to fit: R_X86_64_PC32 against undefined symbol `_ITM_RU8'
/usr/lib/gcc/x86_64-w64-mingw32/7.3-win32/libstdc++.a(cow-stdexcept.o):(.text$_ZGTtNSt11logic_errorD0Ev+0x1a): additional relocation overflows omitted from the output
collect2: error: ld returned 1 exit status
Makefile:14442: recipe for target 'libdshow_plugin.la' failed
make[4]: *** [libdshow_plugin.la] Error 1
make[4]: Leaving directory '/home/js/vlcca/winV3/win64/modules'
Makefile:29545: recipe for target 'all-recursive' failed
make[3]: *** [all-recursive] Error 1
make[3]: Leaving directory '/home/js/vlcca/winV3/win64/modules'
Makefile:11667: recipe for target 'all' failed
make[2]: *** [all] Error 2
make[2]: Leaving directory '/home/js/vlcca/winV3/win64/modules'
Makefile:1569: recipe for target 'all-recursive' failed
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory '/home/js/vlcca/winV3/win64'
Makefile:1454: recipe for target 'all' failed
make: *** [all] Error 2
这个问题碰到很多次,各种版本的vlc,3.07,3.08,4.0dev都是,与gcc版本没有关系,但有mingw-w64版本密切相关,官方提示要5.0版本,就一定要满足,否则必有问题,回想起来:这个是整个vlc编译的最核心问题。
15、准备装http://mirrors.163.com/ubuntu/pool/universe/f/faad2/faad_2.8.8-1_amd64.deb
http://mirrors.163.com/ubuntu/pool/universe/f/faad2/libfaad2_2.8.8-1_amd64.deb
configure: error: cannot find FAAD library
安装后仍然提示没有,只能disable-faad
sudo update-alternatives --install /usr/bin/FAAD FAAD /usr/bin/faac 80
########################后记,下面问题也是由于mingw-w64版本不对,记得不是gcc版本,而是gcc-mingw-w64-x86-64 g++-mingw-w64-x86-64这个相关tooltrain的版本,一定要5.x
使用9.0出现这些问题:
../../modules/access/imem.c:264:28: warning: cast from function call of type ‘long long unsigned int’ to non-matching type ‘void *’ [-Wbad-function-cast]
sys->source.data = (void *)(uintptr_t)strtoull(tmp, NULL, 0);
^
CCLD libaccess_imem_plugin.la
CC access/sdp.lo
CCLD libsdp_plugin.la
CC access/timecode.lo
CCLD libtimecode_plugin.la
CC access/vdr.lo
CCLD libvdr_plugin.la
CC access/wasapi.lo
CCLD libaccess_wasapi_plugin.la
CC access/shm.lo
CCLD libshm_plugin.la
CXX access/dshow/libdshow_plugin_la-dshow.lo
CXX access/dshow/libdshow_plugin_la-filter.lo
/usr/bin/x86_64-w64-mingw32-as: BFD (GNU Binutils) 2.30 assertion fail ../../../upstream/bfd/coff-x86_64.c:696
/tmp/ccIIAk6m.s: Assembler messages:
/tmp/ccIIAk6m.s:39: Error: cannot represent relocation type BFD_RELOC_X86_64_GOTPC64
/usr/bin/x86_64-w64-mingw32-as: BFD (GNU Binutils) 2.30 assertion fail ../../../upstream/bfd/coff-x86_64.c:696
/tmp/ccIIAk6m.s:299: Error: cannot represent relocation type BFD_RELOC_X86_64_GOTPC64
/usr/bin/x86_64-w64-mingw32-as: BFD (GNU Binutils) 2.30 assertion fail ../../../upstream/bfd/coff-x86_64.c:696
/tmp/ccIIAk6m.s:766: Error: cannot represent relocation type BFD_RELOC_X86_64_GOTPC64
/usr/bin/x86_64-w64-mingw32-as: BFD (GNU Binutils) 2.30 assertion fail ../../../upstream/bfd/coff-x86_64.c:696
/tmp/ccIIAk6m.s:823: Error: cannot represent relocation type BFD_RELOC_X86_64_GOTPC64
/usr/bin/x86_64-w64-mingw32-as: BFD (GNU Binutils) 2.30 assertion fail ../../../upstream/bfd/coff-x86_64.c:696
/tmp/ccIIAk6m.s:881: Error: cannot represent relocation type BFD_RELOC_X86_64_GOTPC64
/usr/bin/x86_64-w64-mingw32-as: BFD (GNU Binutils) 2.30 assertion fail ../../../upstream/bfd/coff-x86_64.c:696
/tmp/ccIIAk6m.s:938: Error: cannot represent relocation type BFD_RELOC_X86_64_GOTPC64
/usr/bin/x86_64-w64-mingw32-as: BFD (GNU Binutils) 2.30 assertion fail ../../../upstream/bfd/coff-x86_64.c:696
/tmp/ccIIAk6m.s:1619: Error: cannot represent relocation type BFD_RELOC_X86_64_GOTPC64
/usr/bin/x86_64-w64-mingw32-as: BFD (GNU Binutils) 2.30 assertion fail ../../../upstream/bfd/coff-x86_64.c:696
/tmp/ccIIAk6m.s:2413: Error: cannot represent relocation type BFD_RELOC_X86_64_GOTPC64
/usr/bin/x86_64-w64-mingw32-as: BFD (GNU Binutils) 2.30 assertion fail ../../../upstream/bfd/coff-x86_64.c:696
/tmp/ccIIAk6m.s:12807: Error: cannot represent relocation type BFD_RELOC_X86_64_GOTPC64
Makefile:25238: recipe for target 'access/dshow/libdshow_plugin_la-filter.lo' failed
make[4]: *** [access/dshow/libdshow_plugin_la-filter.lo] Error 1
make[4]: Leaving directory '/home/js/vlcca/winV3/win64/modules'
Makefile:29545: recipe for target 'all-recursive' failed
make[3]: *** [all-recursive] Error 1
make[3]: Leaving directory '/home/js/vlcca/winV3/win64/modules'
Makefile:11667: recipe for target 'all' failed
make[2]: *** [all] Error 2
make[2]: Leaving directory '/home/js/vlcca/winV3/win64/modules'
Makefile:1569: recipe for target 'all-recursive' failed
安装最新的java https://www.oracle.com/technetwork/java/javase/downloads/jdk13-downloads-5672538.html 下载deb到windows,然后拷贝到Ubuntu sudo dpkd -i xx.deb 安装
/usr/lib/jvm/jdk-13.0.1/
#############后记##############
这里我下载了最新版本,以为高版本怎么都可以满足低版本的要求,后来吃了大亏,一定要装jdk1.8,也即jdk8
吐槽:oracle作死的节奏,下载一个jdk还要注册,至少花费了30分钟注册,认证,下载,java是自由软件,现在变得如此封闭,没有路。其次,其网站登录跳来跳去,机械,体验太差,看来oracle讲进入暮年了。
###########################
保存退出
# sudo gedit /etc/environment
在最后添加一行:
JAVA_HOME=/home/js/jdk1.8.0_231/
保存退出
使jdk环境变量生效
# source /etc/profile
检查jdk是否生效
# java -version
# javac -version
js@ubuntu:$ java -version
java version "1.8.0_231"
Java(TM) SE Runtime Environment (build 1.8.0_231-b11)
Java HotSpot(TM) 64-Bit Server VM (build 25.231-b11, mixed mode)
继续安装,如果是在其它终端做的上述操作,在编译终端也须执行下:
# source /etc/profile
然后再看版本。
export JAVA_HOME=/home/js/jdk1.8.0_231/
export JAVA_BIN=$JAVA_HOME/bin
export JAVA_LIB=$JAVA_HOME/lib
export CLASSPATH=.:$JAVA_LIB/tools.jar:$JAVA_LIB/dt.jar
export PATH=$JAVA_BIN:$PATH
保存退出
# sudo gedit /etc/environment
在最后添加一行:
JAVA_HOME="/home/js/jdk1.8.0_231/"
保存退出
sudo gedit /etc/profile
尾部添加:
export JAVA_HOME=/home/js/jdk1.8.0_231/
export JAVA_BIN=$JAVA_HOME/bin
export JAVA_LIB=$JAVA_HOME/lib
export CLASSPATH=.:$JAVA_LIB/tools.jar:$JAVA_LIB/dt.jar
export PATH=$JAVA_BIN:$PATH
# source /etc/profile
###################缺少头文件的终极处理方法#######################
一开始想把头文件增加到path路径,后来证实不行,查找网上可以修改CPLUS_INCLUDE_PATH等环境变量,但是悲催,vlc的脚本根本不认可
也尝试过export临时修改,都不行。
最后解决的办法是:
1、找到你的include目录,这个要根据提示缺少什么就去安装什么,比如我这里缺少glew.h 这个要安装glew,之后会在/usr/include/EL/这个目录找到所有glew相关的头文件
2、拷贝他到vlc目录下的include目录,为了安全期间,我还在win64/include目录下也放了一份,这两个目录是整个vlc编译都会加入的include目录,所以,放在在这里自然会被找到。
实际上修改configure.ac或内部编译脚本也可以,但是vlc内部的子目录的makefile全部是运行时生成的,找到准确位置修改很难。
####################
CPLUS_INCLUDE_PATH=$CPLUS_INCLUDE_PATH:/usr/include
C_INCLUDE_PATH=$C_INCLUDE_PATH:/usr/include
export C_INCLUDE_PATH
export CPLUS_INCLUDE_PATH
我感觉到最新的vlc需要qt5,而不是qt4,但是qt5如何安装??试过装了是gui版本的,根本没用
##################后记:这个按照官方即可,实际上最要禁用disable-qt,这是我的解决方案,但后果是vlc编译后没有GUI界面,但不影响libvlc整体功能。
改用3.071编译:
====================================
glew-1.7.0/doc/wglew.html
(cd glew-1.7.0 && patch -fp1) < ../../contrib/src/glew/win32.patch
patching file Makefile
patching file config/Makefile.mingw
patching file include/GL/glew.h
mv glew-1.7.0 glew && touch glew
cd glew && CC="x86_64-w64-mingw32-gcc" CXX="x86_64-w64-mingw32-g++" LD="x86_64-w64-mingw32-ld" AR="x86_64-w64-mingw32-ar" CCAS="x86_64-w64-mingw32-gcc -c" RANLIB="x86_64-w64-mingw32-ranlib" STRIP="x86_64-w64-mingw32-strip" PATH="/home/js/vlcca/3.0.7.1/vlc-3.0/contrib/x86_64-w64-mingw32/bin:/home/js/vlcca/3.0.7.1/vlc-3.0/extras/tools/build/bin:/home/js/bin:/home/js/.local/bin:/home/js/jdk1.8.0_231//bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/home/js/Android/Sdk/tools:/home/js/Android/Sdk/platform-tools:/home/js/ndk/android-ndk-r18b" CPPFLAGS=" -I/home/js/vlcca/3.0.7.1/vlc-3.0/contrib/x86_64-w64-mingw32/include" CFLAGS=" -I/home/js/vlcca/3.0.7.1/vlc-3.0/contrib/x86_64-w64-mingw32/include -g -O2" CXXFLAGS=" -I/home/js/vlcca/3.0.7.1/vlc-3.0/contrib/x86_64-w64-mingw32/include -g -O2" LDFLAGS=" -L/home/js/vlcca/3.0.7.1/vlc-3.0/contrib/x86_64-w64-mingw32/lib " CFLAGS=" -I/home/js/vlcca/3.0.7.1/vlc-3.0/contrib/x86_64-w64-mingw32/include -g -O2 -DGLEW_STATIC" make
make[1]: Entering directory '/home/js/vlcca/3.0.7.1/vlc-3.0/contrib/win64/glew'
x86_64-w64-mingw32-gcc -DGLEW_NO_GLU -O2 -Wall -W -Iinclude -DGLEW_BUILD -DSTATIC -o src/glew.o -c src/glew.c
x86_64-w64-mingw32-ld -o lib/glew32.dll src/glew.o -L/mingw/lib -lglu32 -lopengl32 -lgdi32 -luser32 -lkernel32
x86_64-w64-mingw32-ld: cannot find -lglu32
x86_64-w64-mingw32-ld: cannot find -lopengl32
x86_64-w64-mingw32-ld: cannot find -lgdi32
x86_64-w64-mingw32-ld: cannot find -luser32
x86_64-w64-mingw32-ld: cannot find -lkernel32
Makefile:101: recipe for target 'lib/glew32.dll' failed
make[1]: *** [lib/glew32.dll] Error 1
make[1]: Leaving directory '/home/js/vlcca/3.0.7.1/vlc-3.0/contrib/win64/glew'
../../contrib/src/glew/rules.mak:22: recipe for target '.glew' failed
make: *** [.glew] Error 2
最后尝试完全使用mingw-64503
卸载:
js@ubuntu:~/vlcca/vlcgithubandroid/vlcwin64/tools/mingw-w64$ sudo apt-get autoremove gcc-mingw-w64-x86-64 g++-mingw-w64-x86-64 mingw-w64-tools
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages will be REMOVED:
binutils-mingw-w64-i686 binutils-mingw-w64-x86-64 g++-mingw-w64 g++-mingw-w64-i686 g++-mingw-w64-x86-64 gcc-mingw-w64
gcc-mingw-w64-base gcc-mingw-w64-i686 gcc-mingw-w64-x86-64 libqt5concurrent5 mingw-w64 mingw-w64-common mingw-w64-i686-dev
mingw-w64-tools mingw-w64-x86-64-dev qt5-qmake qt5-qmake-bin qtbase5-dev-tools
0 upgraded, 0 newly installed, 18 to remove and 42 not upgraded.
After this operation, 775 MB disk space will be freed.
Do you want to continue? [Y/n]
(Reading database ... 227064 files and directories currently installed.)
Removing mingw-w64 (5.0.3-1) ...
Removing g++-mingw-w64 (7.3.0-11ubuntu1+20.2build1) ...
Removing g++-mingw-w64-i686 (7.3.0-11ubuntu1+20.2build1) ...
Removing gcc-mingw-w64 (7.3.0-11ubuntu1+20.2build1) ...
Removing gcc-mingw-w64-i686 (7.3.0-11ubuntu1+20.2build1) ...
Removing binutils-mingw-w64-i686 (2.30-7ubuntu1+8ubuntu1) ...
Removing g++-mingw-w64-x86-64 (7.3.0-11ubuntu1+20.2build1) ...
Removing gcc-mingw-w64-x86-64 (7.3.0-11ubuntu1+20.2build1) ...
Removing binutils-mingw-w64-x86-64 (2.30-7ubuntu1+8ubuntu1) ...
Removing gcc-mingw-w64-base (7.3.0-11ubuntu1+20.2build1) ...
Removing libqt5concurrent5:amd64 (5.9.5+dfsg-0ubuntu2.3) ...
Removing mingw-w64-i686-dev (6.0.0-3) ...
Removing mingw-w64-x86-64-dev (6.0.0-3) ...
Removing mingw-w64-common (6.0.0-3) ...
Removing mingw-w64-tools (6.0.0-3) ...
Removing qt5-qmake:amd64 (5.9.5+dfsg-0ubuntu2.3) ...
Removing qt5-qmake-bin (5.9.5+dfsg-0ubuntu2.3) ...
Removing qtbase5-dev-tools (5.9.5+dfsg-0ubuntu2.3) ...
Processing triggers for man-db (2.8.3-2ubuntu0.1) ...
Processing triggers for libc-bin (2.27-3ubuntu1) ...
To build vlc and its plugins, type `make', or `./compile' if you like nice colors.
----------------make2--------------------------
make all-recursive
make[1]: Entering directory '/home/js/vlcca/3.0.7.1/vlc-3.0/win64'
Making all in compat
make[2]: Entering directory '/home/js/vlcca/3.0.7.1/vlc-3.0/win64/compat'
make all-am
make[3]: Entering directory '/home/js/vlcca/3.0.7.1/vlc-3.0/win64/compat'
make[3]: Nothing to be done for 'all-am'.
make[3]: Leaving directory '/home/js/vlcca/3.0.7.1/vlc-3.0/win64/compat'
make[2]: Leaving directory '/home/js/vlcca/3.0.7.1/vlc-3.0/win64/compat'
Making all in doc
make[2]: Entering directory '/home/js/vlcca/3.0.7.1/vlc-3.0/win64/doc'
make[2]: Nothing to be done for 'all'.
make[2]: Leaving directory '/home/js/vlcca/3.0.7.1/vlc-3.0/win64/doc'
Making all in po
make[2]: Entering directory '/home/js/vlcca/3.0.7.1/vlc-3.0/win64/po'
make[2]: Nothing to be done for 'all'.
make[2]: Leaving directory '/home/js/vlcca/3.0.7.1/vlc-3.0/win64/po'
Making all in share
make[2]: Entering directory '/home/js/vlcca/3.0.7.1/vlc-3.0/win64/share'
make[2]: Nothing to be done for 'all'.
make[2]: Leaving directory '/home/js/vlcca/3.0.7.1/vlc-3.0/win64/share'
Making all in src
make[2]: Entering directory '/home/js/vlcca/3.0.7.1/vlc-3.0/win64/src'
GEN stamp-revision
fatal: Not a valid object name HEAD
make all-am
make[3]: Entering directory '/home/js/vlcca/3.0.7.1/vlc-3.0/win64/src'
CCLD libvlccore.la
/home/js/vlcca/3.0.7.1/vlc-3.0/contrib/x86_64-w64-mingw32/lib/libintl.a(printf.o): In function `libintl_vprintf':
/home/js/vlcca/3.0.7.1/vlc-3.0/contrib/win64/gettext/gettext-tools/intl/../../gettext-runtime/intl/printf.c:138: undefined reference to `__imp___acrt_iob_func'
/home/js/vlcca/3.0.7.1/vlc-3.0/contrib/win64/gettext/gettext-tools/intl/../../gettext-runtime/intl/printf.c:138:(.text+0x2a33): relocation truncated to fit: R_X86_64_PC32 against undefined symbol `__imp___acrt_iob_func'
/home/js/vlcca/3.0.7.1/vlc-3.0/contrib/win64/gettext/gettext-tools/intl/../../gettext-runtime/intl/printf.c:138: undefined reference to `__imp___acrt_iob_func'
/home/js/vlcca/3.0.7.1/vlc-3.0/contrib/win64/gettext/gettext-tools/intl/../../gettext-runtime/intl/printf.c:138:(.text+0x2a79): relocation truncated to fit: R_X86_64_PC32 against undefined symbol `__imp___acrt_iob_func'
/home/js/vlcca/3.0.7.1/vlc-3.0/contrib/x86_64-w64-mingw32/lib/libintl.a(printf.o): In function `libintl_vwprintf':
/home/js/vlcca/3.0.7.1/vlc-3.0/contrib/win64/gettext/gettext-tools/intl/../../gettext-runtime/intl/printf.c:368: undefined reference to `__imp___acrt_iob_func'
/home/js/vlcca/3.0.7.1/vlc-3.0/contrib/win64/gettext/gettext-tools/intl/../../gettext-runtime/intl/printf.c:368:(.text+0x56e3): relocation truncated to fit: R_X86_64_PC32 against undefined symbol `__imp___acrt_iob_func'
/home/js/vlcca/3.0.7.1/vlc-3.0/contrib/win64/gettext/gettext-tools/intl/../../gettext-runtime/intl/printf.c:368: undefined reference to `__imp___acrt_iob_func'
/home/js/vlcca/3.0.7.1/vlc-3.0/contrib/win64/gettext/gettext-tools/intl/../../gettext-runtime/intl/printf.c:368:(.text+0x5729): relocation truncated to fit: R_X86_64_PC32 against undefined symbol `__imp___acrt_iob_func'
collect2: error: ld returned 1 exit status
Makefile:2238: recipe for target 'libvlccore.la' failed
make[3]: *** [libvlccore.la] Error 1
make[3]: Leaving directory '/home/js/vlcca/3.0.7.1/vlc-3.0/win64/src'
Makefile:1791: recipe for target 'all' failed
make[2]: *** [all] Error 2
make[2]: Leaving directory '/home/js/vlcca/3.0.7.1/vlc-3.0/win64/src'
Makefile:1552: recipe for target 'all-recursive' failed
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory '/home/js/vlcca/3.0.7.1/vlc-3.0/win64'
Makefile:1437: recipe for target 'all' failed
make: *** [all] Error 2
opengl/converter.h:49:24: fatal error: GL/glew.h: No such file or director
http://mirrors.163.com/ubuntu/pool/universe/g/glew/
这个要安装glew,然后把安装后再/usr/include/的EL目录拷贝到vlc源代码的几个include目录下即可,其他解决方案我找了好久没有解决问题
最后终于成功生成 vlc3.071版本的exe程序,我以为自己不会成功,但是坚持到了最后成功了,泪奔三尺,亦苦亦甜!
复制生成的打包文件,补充下载了一个libssp-0.dll后播放命令行 vlc video.mp4 成功播放,也有声音。
一定要gcc-mingw-w64-x86-64 g++-mingw-w64-x86-64 mingw-w64-tools 这几个工具都是5.x版本的,不能是6.0,否则会出现relocation _ITM_memcpyRnWt——————错误
FAAD错误可以警用
#########后记综合########################
1、用同样的环境和方法,编译3.08版本出现如下问题,暂时未找到问题根源,估计又是环境的问题
touch .dxgitype
mkdir -p dxgi12
cp ../tarballs/dxgi1_2.idl dxgi12 && cd dxgi12 && patch -fp1 < ../../src/d3d11/dxgi12.patch
patching file dxgi1_2.idl
mkdir -p -- "/home/js/vlcca/vlcgithubandroid/vlcwin64/vlc30/vlc/contrib/x86_64-w64-mingw32/include/"
x86_64-w64-mingw32-widl -DBOOL=WINBOOL -I/home/js/vlcca/vlcgithubandroid/vlcwin64/vlc30/vlc/contrib/x86_64-w64-mingw32/include -I/usr/include/wine/windows/ -I/usr/include/wine/wine/windows/ -h -o /home/js/vlcca/vlcgithubandroid/vlcwin64/vlc30/vlc/contrib/x86_64-w64-mingw32/include/dxgi1_2.h dxgi12/dxgi1_2.idl
/usr/include/wine/windows/winnt.h:2114:1: Error: #error directive: 'You need to define a CONTEXT for your CPU'
../src/d3d11/rules.mak:83: recipe for target '/home/js/vlcca/vlcgithubandroid/vlcwin64/vlc30/vlc/contrib/x86_64-w64-mingw32/include/dxgi1_2.h' failed
make: *** [/home/js/vlcca/vlcgithubandroid/vlcwin64/vlc30/vlc/contrib/x86_64-w64-mingw32/include/dxgi1_2.h] Error 1
这个是少了d开头的几个头文件,见office文档说明(https://docs.microsoft.com/zh-cn/windows/win32/api/_direct3ddxgi/index)
patching file fxc2.cpp
Hunk #1 succeeded at 217 (offset 1 line).
Hunk #2 succeeded at 236 (offset 1 line).
Hunk #3 succeeded at 311 (offset 1 line).
Hunk #4 succeeded at 320 (offset 1 line).
mv fxc2-git-63ad74b7faa7033f2c1be9cc1cd0225241a1a9a5 fxc2 && touch fxc2
cd fxc2 && x86_64-w64-mingw32-g++ -static fxc2.cpp -o fxc2.exe
fxc2.cpp: In function ‘int main(int, const char**)’:
fxc2.cpp:295:28: error: ‘nullptr’ was not declared in this scope
LPSTR messageBuffer = nullptr;
^
../src/fxc2/rules.mak:43: recipe for target '.fxc2' failed
make: *** [.fxc2] Error 1
找到这个文件,然后把nullptr替换成NULL
4.0dev和3.08都试过使用同样的环境进行编译,但是失败,而4.0好像需要gcc8,3.08也出现很多错误
编译脚本内容(sh文件):
#! /bin/sh
set -e
# vlc win32 complie shell by yangxun
#andy add
export BUILDCC=/usr/bin/gcc
#export CFLAGS="-fPIC"
#export CXXFLAGS="-fPIC"
#export CFLAGS="-I/usr/include"
#export CXXFLAGS="-I/usr/include"
# function define
diagnostic()
{
echo "$@" 1>&2;
}
checkfail()
{
if [ ! $? -eq 0 ]; then
diagnostic "$1"
exit 1
fi
}
# arg get
while [ $# -gt 0 ]; do
case $1 in
--help|-h)
echo "Use -a to set Host triplet"
echo " i686-w64-mingw32 for Windows 32-bits"
echo " x86_64-w64-mingw32 for Windows 64-bits"
exit 0
;;
-a)
HOST_TRIPLET=$2
shift
;;
esac
shift
done
# set default host triplet
if [ -z ${HOST_TRIPLET} ]; then
#diagnostic "*** No HOST_TRIPLET defined,using i686-w64-mingw32"
diagnostic "*** No HOST_TRIPLET defined,using -a to set it"
exit 1
#HOST_TRIPLET="i686-w64-mingw32"
else
diagnostic "*** HOST_TRIPLET=${HOST_TRIPLET}"
fi
# detect build folder
if [ ${HOST_TRIPLET} = "i686-w64-mingw32" ]; then
MY_BUILD_FOLDER="win32"
fi
if [ ${HOST_TRIPLET} = "x86_64-w64-mingw32" ]; then
MY_BUILD_FOLDER="win64"
fi
# built
CONTRIB_CONFIG="
--disable-gcrypt
--disable-ssh2
--disable-vncclient
--disable-projectM
--disable-bluray
--disable-qt
--disable-qtsvg
--disable-sdl
--disable-SDL_image
--disable-glew"
#CONTRIB_CONFIG=""
mkdir -p contrib/${MY_BUILD_FOLDER}
cd contrib/${MY_BUILD_FOLDER}
echo "----------------bootstrap022222222222222222222--------------------------"
../bootstrap --host=${HOST_TRIPLET} ${CONTRIB_CONFIG}
echo "----------------fetch--------------------------"
make fetch
checkfail "contrib fetch failed"
#echo "----------------make clean################################--------------------------"
#make clean
echo "----------------make--------------------------"
make
checkfail "contrib make failed"
rm -f ../i686-w64-mingw32/bin/moc ../i686-w64-mingw32/bin/uic ../i686-w64-mingw32/bin/rcc
if [ ${HOST_TRIPLET} != "i686-w64-mingw32" ]; then
ln -sf ${HOST_TRIPLET} ../i686-w64-mingw32
fi
echo "----------------go back--------------------------"
# go back vlc root dir
cd -
# compile vlc
OPTIONS="
--disable-faad
--enable-flac
--enable-theora
--enable-twolame
--enable-avcodec
--enable-merge-ffmpeg
--enable-dca
--enable-mpc
--enable-libass
--enable-x264
--enable-schroedinger
--enable-realrtsp
--enable-live555
--enable-shout
--enable-caca
--enable-sse
--enable-mmx
--enable-zvbi
--disable-telx
--enable-nls
--disable-update-check
--disable-libcrypt
--disable-lua
--disable-goom
--disable-projectm
--disable-vsxu
--disable-vnc
--disable-vcd
--disable-libcddb
--disable-freerdp
--disable-opencv
--disable-dc1394
--disable-dv1394
--disable-dvdread
--disable-dvdnav
--disable-bluray
--disable-sdl-image
--disable-skins2
--disable-qt
--disable-a52"
#OPTIONS=""
#OPTIONS="
# --disable-qt"
echo "----------------bootstrap23333333333333--------------------------"
./bootstrap
mkdir -p ${MY_BUILD_FOLDER} && cd ${MY_BUILD_FOLDER}
export PKG_CONFIG_LIBDIR=$HOME/vlc/contrib/${HOST_TRIPLET}/lib/pkgconfig
echo "----------------configure2--------------------------"
CFLAGS=-fPIC
../configure --host=${HOST_TRIPLET} --build=x86_64-pc-linux-gnu ${OPTIONS}
echo "----------------make2--------------------------"
make
checkfail "vlc make failed"
make package-win32-zip
checkfail "vlc make package failed"