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

来源:互联网 发布:java程序调用rest api 编辑:程序博客网 时间:2024/05/18 20:08

VLC 3.0.0 Compile

vlc的编译一直是个大坑,做过音视频开发的不少人想必都踩过,开篇引用官方wiki一句话:

Compiling VLC is not an easy task.

本文记录了笔者在Linux和Windows下编译VLC-3.0.0 Nightly发布版的详细过程,供各位爬坑参考。嗯,就酱, good luck :)

Linux 编译

System

编译使用了Ubuntu 14.04 x64 LTS版(16.x应该也没问题)

GCC & G++

VLC要求编译器支持c/c++11,不然”./configure”时候报错。Ubuntu14.04自带的GCC4.8(”gcc -v”可查看版本),故升级至5.4.1。

GCC & G++安装

添加PPA并安装

sudo add-apt-repository ppa:ubuntu-toolchain-r/test
sudo apt-get update
sudo apt-get upgrade
sudo apt-get install gcc-5 g++-5

更新链接

sudo ln -s /usr/bin/gcc-5 /usr/bin/gcc -f
sudo ln -s /usr/bin/g++-5 /usr/bin/g++ -f

安装构建工具

sudo apt-get install git build-essential pkg-config libtool automake autopoint gettext

安装VLC编译需要的库(Contrib)

参考链接: Wiki_VLC_Contrib Status

官方给的contrib有一些已经失效了,故进行了替换。命令如下:

sudo apt-get build-dep vlc

sudo apt-get -y install libvorbis-dev libogg-dev libtheora-dev speex \
libspeex-dev flac libflac-dev x264 libx264-dev a52-0.7.4 liba52-0.7.4-dev \
mpeg2dec libmpeg2-4-dev faad libfaad-dev faac libfaac-dev lame libmp3lame-dev \
libavdevice-dev libmad0 libmad0-dev libschroedinger-dev libebml-dev libdca-dev \
twolame libtwolame-dev libmpcdec-dev libvorbisidec1 libvorbisidec-dev \
libass-dev libmatroska-dev libdvbpsi-dev libmodplug1 libmodplug-dev libshout3 \
libshout3-dev libdvdread4 libdvdnav4 libdvdnav-dev livemedia-utils \
liblivemedia-dev libcddb2 libcddb2-dev libcdio13 libcdio-dev \
libxcb-composite0-dev libcdio-utils vcdimager libvcdinfo0 libvcdinfo-dev \
libgpg-error0 libgpg-error-dev libgcrypt11-dev gnutls-bin libgnutls-dev \
libdap-bin libdap-dev libxml2 libxml2-dev libpng12-0 libpng12-dev libjpeg8 \
libtiff5 libsdl1.2-dev libsdl-image1.2 libsdl-image1.2-dev libc-bin gettext \
libfreetype6 libfreetype6-dev libfribidi-dev libfribidi0 zlib1g zlib1g-dev \
libtag1-dev libcaca0 libcaca-dev caca-utils libqt4-dev libportaudio2 \
libupnp-dev libupnp6 libexpat1 libexpat1-dev yasm libxcb-xv0 libxcb-xv0-dev \
libx11-xcb1 libx11-xcb-dev liblua5.2-dev libswscale-dev

ffmpeg

需要安装ffmpeg并且要求libavcodec版本在57以上(含)。
如果之前装过从命令行输入:

ffmpeg

查看一下libavcodec版本,
1. 如果是57之前的版本, “apt-get autoremove ffmpeg” 删了准备重装吧。
2. 如果符合要求,可跳过安装ffmpeg的步骤。

ffmpeg安装

官方给的PPA上,libavcodec版本是56,所以直接用源码安装。

安装yasm

sudo apt-get install yasm

从官网clone最新的git仓库

git clone https://git.ffmpeg.org/ffmpeg.git
cd ./ffmpeg

指定install目录为”./host”,指定编译为动态库,开始编译。

./configure –prefix=host –enable-shared –disable-doc
make && make install

把生成的动态库文件拷贝到”/usr/bin/”目录下

cd ./host/lib
sudo cp ./* /usr/bin/

安装完成,可以切到host/bin目录下执行一下”./ffmpeg”确认。

VLC 3.0.0 编译

确认上述准备工作完成之后,总算可以开始编译VLC 3.0.0了。

先去VLC官网下载vlc-3.0.0-nightly版代码: VLC Source
这里以我用的”vlc-3.0.0-20171129-0230-git.tar.xz”为例。

cd /root/Desktop/
wget https://nightlies.videolan.org/build/source/vlc-3.0.0-20171129-0230-git.tar.xz
tar -Jcf vlc-3.0.0-20171129-0230-git.tar.xz
cd ./vlc-3.0.0-git
./bootstrap

运行configure,参数可参考: VLC_Configure

mkdir ./out
./configure –prefix=/root/Desktop/vlc-3.0.0-git/out/ –disable-qt –enable-run-as-root

编译安装(这步需要科学上网)

make && make install

Windows 编译

交叉编译work
~~TODO~~

原创粉丝点击