Skip to content

GPAC Build Guide for Linux

Romain Bouqueau edited this page May 25, 2022 · 9 revisions
Clone this wiki locally

HOME » Build » Linux

Preliminary notes: the following instructions will be based on Ubuntu and Debian. It should be easily applicable to other distributions, the only changes should be name of the packages to be installed, and the package manager used.

GPAC is a modular piece of software which depends on third-party libraries. During the build process it will try to detect and leverage the installed third-party libraries on your system. Here are the instructions to:

  • build GPAC easily (recommended for most users) from what's available on your system,
  • build a minimal 'MP4Box' and 'gpac' (only contains GPAC core features like muxing and streaming),
  • build a complete GPAC by rebuilding all the dependencies manually.

Setting up the environement

Development tools

We first need to install some building tools:

$ sudo apt-get install build-essential pkg-config g++ git scons cmake yasm

Get the code

$ git clone https://github.com/gpac/gpac.git
$ cd gpac

Build (general case)

$ ./configure
$ make

To parallelize the build you can use the -j option of Make.

Upgrade

$ git pull
$ make

If this fails, do make clean.

If this fails again, reconfigure your GPAC with the same option as you previously did: ./configure --xxx .... You can find these options at the top of your config.mak or config.h files (located in the folder where you call the configure script from).

If you are upgrading from a previous version (especially going from below 1.0.0 to 1.0.0+) you should run make uninstall ; make distclean before running ./configure.

Use

You can either:

  • sudo make install to install the binaries,
  • or use the MP4Box or gpac binary in gpac_public/bin/gcc/ directly,
  • or move/copy it somewhere manually.

GPAC easy build (recommended for most users)

Install the development packages for the third-party libraries GPAC is able to leverage:

$ sudo apt-get install zlib1g-dev libfreetype6-dev libjpeg62-dev libpng-dev libmad0-dev libfaad-dev libogg-dev libvorbis-dev libtheora-dev liba52-0.7.4-dev libavcodec-dev libavformat-dev libavutil-dev libswscale-dev libavdevice-dev libxv-dev x11proto-video-dev libgl1-mesa-dev x11proto-gl-dev libxvidcore-dev libssl-dev libjack-dev libasound2-dev libpulse-dev libsdl2-dev dvb-apps mesa-utils

This list should work on Ubuntu from 14.04 (trusty) to at least 21.10 (impish).

If you use Debian instead of Ubuntu, replace libjpeg62-dev with libjpeg62-turbo-dev. It should work on at least Debian 9 (stretch) and 10 (buster).

[Also tested on archlinux-2022.02.01-x86_64 with the following: pacman -S zlib freetype2 libjpeg-turbo libpng libmad faad2 libogg libvorbis libtheora a52dec ffmpeg libxv mesa glu xvidcore openssl jack2 alsa-lib libpulse sdl2]

MP4Box & gpac only (minimal static build)

This build is intended if you only need GPAC core features such as demuxing, muxing and streaming or if you need a static build.

To build only the MP4Box and gpac command line utilities, you need to:

  1. Install build tools
$ sudo apt-get install build-essential pkg-config git
  1. Install zlib
$ sudo apt-get install zlib1g-dev
  1. Get the code
$ git clone https://github.com/gpac/gpac.git gpac_public
$ cd gpac_public
  1. Build

If you are upgrading from a previous version (especially going from below 1.0.0 to 1.0.0+) you should run make uninstall ; make distclean before running ./configure.

$ ./configure --static-bin
$ make
  1. Use

You can either:

  • sudo make install to install the binaries,
  • or use the MP4Box or gpac binary in gpac_public/bin/gcc/ directly,
  • or move/copy it somewhere manually.

Full GPAC build (advanced users)

In order to do a full build, we'll first have to handle the dependencies. On Linux, we try to rely on system dependencies (i.e. installable packages) as much as possible and only build the rest manually.

Building other dependencies

From now on, we'll call the base working directory <GPAC_ROOT_DIR>.

  1. Get the code
<GPAC_ROOT_DIR>$ git clone https://github.com/gpac/gpac.git gpac_public

<GPAC_ROOT_DIR>$ git clone https://github.com/gpac/deps_unix
<GPAC_ROOT_DIR>$ cd deps_unix
<GPAC_ROOT_DIR>/deps_unix$ git submodule update --init --recursive --force --checkout

The convention of calling the main gpac repository gpac_public here is quite important for some scripts. If you don't you'll have to adapt the scripts in deps_unix.

  1. Build the dependencies
<GPAC_ROOT_DIR>/deps_unix$ ./build_all.sh linux

If all went well, you should see some libs have been copied over to the gpac repository. It should look something like this:

<GPAC_ROOT_DIR>/deps_unix$ ls -l ../gpac_public/extra_lib/lib/gcc/
total 26836
-rw-r--r-- 1 adavid adavid 3160120 Apr  1 14:10 libavcap.a
-rw-r--r-- 1 adavid adavid  329528 Apr  1 14:09 libaxTLS.a
-rw-r--r-- 1 adavid adavid 4555206 Apr  1 14:12 libjs.a
-rw-r--r-- 1 adavid adavid 4764176 Apr  1 14:09 libNeptune.a
-rw-r--r-- 1 adavid adavid 3974842 Apr  1 14:12 libopenhevc.a
-rw-r--r-- 1 adavid adavid 1024832 Apr  1 14:10 libOpenSVCDec.a
-rw-r--r-- 1 adavid adavid 6425232 Apr  1 14:09 libPlatinum.a
-rw-r--r-- 1 adavid adavid  388740 Apr  1 14:09 libPltMediaConnect.a
-rw-r--r-- 1 adavid adavid  621284 Apr  1 14:09 libPltMediaRenderer.a
-rw-r--r-- 1 adavid adavid 1997878 Apr  1 14:09 libPltMediaServer.a
-rw-r--r-- 1 adavid adavid  205428 Apr  1 14:09 libZlib.a

Building GPAC

Now that all the set up is done, we can build gpac by simply doing:

<GPAC_ROOT_DIR>/gpac_public$ ./configure
<GPAC_ROOT_DIR>/gpac_public$ make
<GPAC_ROOT_DIR>/gpac_public$ sudo make install

[on Arch Linux, use ./configure --prefix=/usr since Arch doesn't use /usr/local by default]

Upgrading from a previous version

If you already have a gpac version installed, or if you have already built gpac in the same directory, especially going from a version below 1.0.0 to 1.0.0 and after, you should run

<GPAC_ROOT_DIR>/gpac_public$ make uninstall
<GPAC_ROOT_DIR>/gpac_public$ make distclean

before running ./configure.

Install for developers

If you want to use GPAC for development (in your own code for example), you can use make install-lib.

It will install the necessary libraries and header files. It will also install a gpac.pc file for pkg-config. With it you can easily build projects that use the gpac library with something like:

$ gcc -o example $(pkg-config --cflags gpac) example.c $(pkg-config --libs gpac)

Packaging

To generate a .deb package, you can use make deb.

You will probably have to install some packaging tools to run it:

$ sudo apt-get install fakeroot dpkg-dev devscripts debhelper ccache