Compiling VLC media player 3.0.8 on CentOS 7

The different Linux distributions out there all provide package managers with which allow users to install 3rd party software, such as yum for systems based on Red Hat or apt-get for Debian based systems. These package managers are customizable software tools that make use of software repositories, that point to servers from which the desired software can be downloaded and installed.


In case you can't find the specific release for a software you need, the only choice you have is to compile it yourself. For example, as I am writing, the version of the VLC media player that can be installed for CentOS 7 is somewhat dated. Therefore we'll discuss how the latest version of it can be compiled...



The work to do breaks down as follows:


1. Install the dependencies that are available via system repositories.


2. Install all those dependencies of VLC that aren't available via system repositories.


3. Compile and install the VLC media player.


4. Run it, play your favourite media and enjoy :).


You will eventually need to make a choice, as to which functionalities VLC is supposed to provide and install the necessary dependencies accordingly. Therefore, your choices may differ somewhat from the ones outlined below. If you want a full list of the 3rd party softare the VLC uses, you can take a look at this link: VLC media player - 3rd party software. However, we'll compile the player with a reasonable choice of dependencies. Let's get to it...



1. Install dependencies of VLC 3.0.8 available in system repositories

The below script installs all those dependencies of VLC that can be found in the system repos. Epel is in this context considered to be a system repo.



#!/bin/sh

#
# Script to install build/run dependencies for vlc-3.0.8.
# All packages come from standard system repos, i.e. base, updates and epel.
#

yum install \
 		libtheora \
		libtheora-devel \
		a52dec \
		liba52 \
		liba52-devel \
		lame \
		lame-devel \
		libmad \
		libmad-devel \
		orc \
		orc-devel \
		schroedinger \
		schroedinger-devel \
		twolame \
		twolame-devel \
		twolame-libs \
		libmpcdec \
		libmpcdec-devel \
		libass \
		libass-devel \
		gsm \
		gsm-devel \
		zvbi \
		zvbi-devel \
		zvbi-fonts \
		libebml \
		libebml-devel \
		libmatroska \
		libmatroska-devel \
		libdvbpsi \
		libdvbpsi-devel \
		libmodplug \
		libmodplug-devel \
		libdvdread \
		libdvdread-devel \
		libdvdnav \
		libdvdnav-devel \
		libcddb \
		libcddb-devel \
		libcdio \
		libcdio-devel \
		gnutls \
		gnutls-devel \
		gnutls-util \
		libxml2 \
		libxml2-devel \
		libtiff \
		libtiff-devel \
		libtiff-tools \
		sdl \
		sdl-devel \
		sdl_image \
		sdl_image-devel \
		autoconf \
		automake \
		pkgconfig \
		libtool \
		libtool-ltdl \
		libtool-ltdl-devel \
		gettext \
		gettext-libs \
		gettext-devel \
		gettext-common-devel \
		freetype2 \
		freetype2-devel \
		fribidi \
		fribidi-devel \
		fontconfig \
		fontconfig-devel \
		taglib \
		taglib-devel \
		projectm \
		projectm-devel \
		projectm-qt \
		projectm-qt-devel \
		projectm-jack \
		projectm-pulseaudio	\
		libcaca \
		libcaca-devel \
		caca-utils \
		qt \
		qt-devel \
		expat \
		expat-devel \
		yasm \
		yasm-devel \
		sqlite \
		sqlite-devel \
		libarchive \
		libarchive-devel \
		libdc1394 \
		libraw1394 \
		libdc1394-devel \
		libraw1394-devel \
		opencv-core \
		opencv-devel \
		opencv \
		libsmbclient \
		libsmbclient-devel \
		freerdp \
		freerdp-devel \
		freerdp-libs \
		freerdp-plugins \
		libsidplayfp \
		libsidplayfp-devel \
		libmfx \
		libmfx-devel \
		fluidsynth \
		fluidsynth-devel \
		fluidsynth-libs \
		xcb-util-keysyms \
		xcb-util-keysyms-devel \
		kate \
		kate-devel \
		librsvg2 \
		librsvg2-tools \
		librsvg2-devel \
		libsamplerate \
		libsamplerate-devel \
		alsa-plugins-samplerate \
		soxr \
		soxr-devel \
		libchromaprint \
		libchromaprint-devel \
		protobuf-lite \
		protobuf-lite-devel \
		libsecret \
		libsecret-devel \
		libmicrodns \
		libmicrodns-devel \
		libnotify \
		libnotify-devel \
		libavc1394 \
		libavc1394-devel \
		libssh2 \
		libssh2-devel \
		libmtp \
		libmtp-devel \
		libnfs \
		libnfs-devel \
		systemd-libs \
		systemd-devel \
		libkate \
		libkate-devel \
		jack-audio-connection-kit-dbus \
		jack-audio-connection-kit-devel \
		libshout \
		libshout-devel

exit 0


2. Install dependencies of VLC 3.0.8 not available in system repositories

We now need to install those link- and runtime dependencies of VLC that can't be obtained via system repositories, either because the versions in the repos are too old or because they're not available in the first place. Here is a list of libraries and applications, that I choose. Everything will be installed under /opt or subfolders thereof, except for Qt (see below), which is only needed to build VLC.



faac-1.29.9.2
faad2-2.7
ffmpeg-4.2
nasm-2.14.02
flac-1.3.1
goom-2k4-0-src
jpegsrc.v9c
last_x264
libav-12.3
libbluray-1.1.2
libdca-0.0.6
libdvdcss-1.4.2
libgcrypt-1.8.4
libgpg-error-1.36
libiconv-1.16
libmpeg2-0.5.1
libogg-1.3.2
libpng-1.6.37
libshout-2.4.3
libvorbis-1.3.5
opus-1.1
pa_stable_v190600_20161030
speex-1.2rc2
speexdsp-1.2.0
taglib-1.11.1
zlib-1.2.11


For a full list of all the tools that VLC can be compiled with can take a look at this website.
To build the tools, you will either need to make use of:

A configure script and make

or

cmake

The configure and compile steps can all be carried out as a regular user. Installing the utilities however requires root access. Since writing to /opt requires root privileges. In case you choose to install the build (and run) dependencies to a directory you control, switching to root before you install won't be necessary. The general steps to be taken when compiling the software are pretty much the same. For that reason, we'll only discuss two examples:


Example 1: Building and installing ffmpeg 4.2 in /opt:

1. Download the file and untar it:

tar -xvf ffmpeg-4.2.tar.gz

2. Descend into the working directory, create a folder named build and cd into it:

cd ffmpeg-4.2 && mkdir build && cd build

3. Run the following script to configure the subsequent build:

Configure ffmpeg 4.2


#!/bin/sh

#
# For libmp3lame install: lame lame-devel lame-libs from the epel-repository.
#

../configure --prefix=/opt/ffmpeg-4.2 \
	--enable-shared \
	--enable-gpl \
	--enable-libmp3lame


4. Run the make command to build the utility:

make

5. Switch to root and run the install target:

su -

make install

Actually, to build ffmpeg, you will most likely need nasm, the netwide assembler. The version that ships with CentOS 7 is not the latest, so you'll most likely need to update. Therefore prior to compiling ffmpeg, I installed nasm 2.14.02 which in my case is installed under /opt/nasm-2.14.02. Since compiling every single 3rd party library/tool would go beyond the scope of this tutorial, building nasm (and the other libraries) is a step, that is left to the avid reader.



Example 2: Installing Qt 5.13.1:

Qt is only need as a build depencency of VLC. For that reason we'll not install in /opt, but simply under somwhere under ${HOME}. After building VLC, Qt can be deleted, unless you may need it for other purposes.


Go to Qt's homepage and download the Qt installer.


Make the file executable with:


$ chmod +x qt-unified-linux-x64-3.1.1-online.run

Now start the installer and download Qt and its libraries:


$ ./qt-unified-linux-x64-3.1.1-online.run

The installer launches a GUI, that shouldn't be too hard to navigate through. To build VLC, it suffices to install: Desktop gcc 64-bit. So select this option and download the files somwhere convenient in your ${HOME} directory. One possible option could be: ${HOME}/vlc_build/qt

As noted above, building and installing the tools is similar, and the rest is left for the interested reader.

3. Building the VLC media player

VLC needs a newer C-compiler than the one that gets shipped with CentOS 7, so switch to a root shell and issue the following two commands:


# yum install centos-release-scl-rh

# yum install devtoolset-7

to obtain a copy of the C-compiler version 7.

If you want to do some follow-up reading on the repo (and tool) just installed, you can follow this link.


We are now in a position to build VLC 3.0.8

1. Go to VLC's homepage, download the source code and untar the downloaded file:

$ tar -xvf vlc-3.0.8.tar.xz

2. Descend into the working directory, create a folder named build and cd into it:

cd vlc-3.0.8 && mkdir build && cd build

3. Activate the version of the C-compiler we just installed:

$ scl enable devtoolset-7 bash

4. Save the following shell script in a file and run it from the build directory:

Configure vlc-3.0.8

#!/bin/sh

#
# Configuration file for vlc-3.0.8
#

export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/opt/lib/lib/pkgconfig:/opt/libebml/lib64/pkgconfig:/home/om/Downloads/qt/5.13.1/gcc_64/lib/pkgconfig:/opt/taglib-1.11.1/lib/pkgconfig:/opt/ffmpeg-4.2/lib/pkgconfig

#
# The following two lines are needed because libfaac and libfaad don't provide .pc files.
#
export CFLAGS="${CFLAGS} -I/opt/lib/include"
export LIBS="${LIBS} -L/opt/lib/lib -lfaac -lfaad"

../configure --prefix=/opt/vlc-3.0.8 \
	--with-libiconv-prefix=/opt/lib \
	--enable-dvdread \
	--enable-dvdnav \
	--enable-dvbpsi \
	--enable-ogg \
	--enable-shout \
	--enable-matroska \
	--enable-mad \
	--enable-mpg123 \
	--enable-merge-ffmpeg \
	--enable-twolame \
	--enable-a52 \
	--with-a52=/opt/lib \
	--enable-flac \
	--enable-libmpeg2 \
	--enable-vorbis \
	--enable-speex \
	--enable-opus \
	--enable-theora \
	--enable-schroedinger \
	--enable-png \
	--enable-jpeg \
	--enable-zvbi \
	--enable-libass \
	--enable-sdl-image \
	--enable-freetype \
	--enable-fribidi \
	--enable-fontconfig \
	--enable-caca \
	--enable-libxml2 \
	--enable-avcodec \
	--enable-faad \
	--enable-x264 \
	--enable-dca=no \
	--enable-vnc=no \
	--enable-live555=no \
	--enable-upnp=no \
	--enable-gme=no \
	--enable-bluray=no \
	--enable-swscale=no


Take a look at the PKG_CONFIG, CFLAGS and LIBS variables in the above script and you can see, where all the dependencies that got compiled in step 2 were installed and which VLC will be enabled in the final executable. Except for Qt, all have been installed under /opt. Moreove, you can see how a configure scripts works hand in hand with PKG_CONFIG which essentially points to the location of the libraries on the system.

5. Run the make command to build the utility:

$ make -j

6. Become root and run the install target:

$ su -

# make install

to install VLC in /opt/vlc-3.0.8


4. Running VLC


#!/bin/sh

export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/opt/lib/lib
/opt/vlc-3.0.8/bin/vlc

exit 0


There you go, you now know how to build VLC 3.0.8 on CentOS 7.