Difference between revisions of "UnixCompile"

From VideoLAN Wiki
Jump to navigation Jump to search
 
(92 intermediate revisions by 26 users not shown)
Line 1: Line 1:
==Prepare your environment==
+
== Prepare your environment ==
VLC uses gcc, automake, autoconf and friends for compilation. Make sure they are up to date and usable for your system.
 
  
==Get the source==
+
VLC requires a C11 compiler, development headers and a toolchain.
Start by [[GetTheSource| getting the source]], using FTP for releases, or using [[Subversion| SVN]] for development.
 
  
If your are using the release, download source code and extract the archive and go into your VLC directory.
+
'''gcc''' (version 4.9 or later) is recommended, but '''clang/LLVM''' are known to work as well.
cd /path/to/your/vlc/folder/
 
  
If you are using the [[SVN]] version, start by debootstraping your VLC.
+
If you build from the [[Git]] repositories, you will also need the GNU build system, also known as the "autotools" (autoconf, automake, libtool and gettext) to setup the Makefiles. Make sure they are up-to-date and usable for your system.
cd /path/to/your/vlc/folder/
 
./bootstrap
 
  
== Get the 3rd party libs ==
+
On Fedora:
Now you can start to configure VLC. Remember to first take a look at ./configure --help. Take a good look at that enormous list of options.
 
  
=== General info ===
+
{{$}} sudo yum install git libtool pkgconfig
It is very important that you install and enable all the 3rd party libraries that you will be needing and let me tell you that that are a lot. If you don't install them you will end up with an application that well..... essentially doesn't do a thing.
 
You can have the full list [[Contrib_Status|here]].
 
  
There are some very important dependancies. gettext (nls) for international support (required), libdvbpsi for mpeg files and streams support, libmad for mp3 decoding, libmpeg2 for mpeg 1 and 2 video support, ffmpeg for support of mpeg4 and many other types of video, liba52 for dolby (AC3) sound, alsa for proper audio output, xvideo for proper video output, wxWidgets (wxGTK) for proper GUI support and libdvd* for DVD support.
+
On Debian or Ubuntu:
  
'''Be careful!''' Some of the libraries are better not to be installed (at all, beware of old installations) and should be linked to directly. These are mostly ffmpeg and liveMedia.  
+
{{$}} sudo apt-get install git g++ make libtool automake autopoint pkg-config flex bison lua5.2
  
There are also some libraries that are no longer being maintained and which we advise not to use. These include the gtk, gnome and kde GUIs, the glide and mga modules.
+
On Arch
 +
{{$}} sudo pacman -S base-devel git pkg-config autoconf automake
  
===Get'em===
+
== Get the source  ==
There are a few ways to get those libs:
+
Start by [[GetTheSource|getting the source]], using FTP for official releases, or using [[Git]] to track VLC development.
  
* Using your distribution or portage system, in order to get all the needed libs:
+
If you are using the [[Git]] development version, start by bootstrapping the source tree:
By example on Debian:
+
{{$}} git clone git://git.videolan.org/vlc.git
  # apt-get build-dep vlc;
+
{{$}} cd vlc
 +
  {{$}} ./bootstrap
 +
Bootstrapping will fail if 'autotools' is missing or out-of-date.
  
* Contribs
+
If you are using an official release, download source code, extract the archive and go into the resulting VLC directory, e.g.:
  % cd extras/contrib;
+
{{$}} wget ftp://ftp.videolan.org/pub/videolan/vlc/{{VLC:latest version}}/vlc-{{VLC:latest version}}.tar.xz
  % ./bootstrap;
+
{{$}} tar xvJf vlc-{{VLC:latest version}}.tar.xz
  % make;
+
{{$}} cd vlc-{{VLC:latest version}}
  
This should download and build a lot of those libs for you.
+
== Get the third-party libraries  ==
 +
Now you can almost [[configure]] the VLC build. But first, you need to make sure that all the required dependencies are in place.
  
 +
You must install and enable all the necessary underlying libraries. If you fail to install a required library, either the configure script or (more likely) you will end up with a crippled VLC program. Furthermore keep in mind that whilst build a program (in this case, VLC), you need to install the '''development packages''' (development header files and import libraries), not just the run-time libraries. On Debian/Ubuntu, the correct package names end with -dev. On RPM distributions, they usually end in -devel.
  
* Read the [[Contrib_Status|list]], then and do it by hand.
+
'''Be careful!''' If the libraries are not provided by your distribution, you may be better off linking VLC with them statically. See the "Contrib" method.
  
== Configuration ==
+
There are a several ways to get those libraries. You should use only one method at a time:
 +
 +
=== The preferred method ===
  
You need to tweak your configure line.
+
Installing the dependencies from the package or portage system is generally much easier and faster. However this only works if your distribution actually ships the necessary libraries. Otherwise, you may need to use the contribs method (see below). It is also possible to combine both methods, picking only the missing bits and pieces from contribs.
  
As with most compilations, you need to run ./configure to get information about your computer, so it can be compiled correctly.
+
==== Debian ====
  ./configure
+
For example on Debian or Ubuntu:
 +
  {{$}} sudo apt-get build-dep vlc
  
===ffmpeg ===
+
==== OpenSuSE ====
Use --with-ffmpeg-tree=path/to/ffmpeg/source/tree and --with-livedotcom-path=path/to/livemedia/source/tree icw. --enable-ffmpeg and --enable-livedotcom
+
openSUSE users might have a look at the source-install (si) command in the zypper manpage:
For ffmpeg it is also important to tell VLC if you compiled ffmpeg with faac and/or lame support. Use the --with-ffmpeg-faac and --with-ffmpeg-mp3lame configure flags.
+
{{$}} sudo zypper si -d vlc
  
=== Final configuration ===
+
'''Note:''' To get the libraries, you must first add the VLC repositories to your system repositories.
If you want to install VLC into another directory, run
+
For example in openSUSE:
  ./configure --prefix=/path/to/install/folder/
+
  {{$}} sudo zypper ar http://download.videolan.org/pub/vlc/SuSE/<openSUSEversion> VLC
 +
You should replace <openSUSEversion> with the version of your system (12.1, 11.4, 11.3, 11.2 or 11.1)
  
This is an example of a typical VLC configure line.
+
=== The "Contrib" method ===
./configure --enable-x11 --enable-xvideo --disable-gtk --enable-sdl --enable-ffmpeg --with-ffmpeg-mp3lame --enable-mad --enable-libdvbpsi --enable-a52
+
If your distribution does not provide the needed libraries or if you really need to link VLC statically, use the VLC contribs system, included in the VLC source.
--enable-dts --enable-libmpeg2 --enable-dvdnav --enable-faad --enable-vorbis --enable-ogg --enable-theora --enable-faac --enable-mkv --enable-freetype
 
--enable-fribidi --enable-speex --enable-flac --enable-livedotcom --with-livedotcom-tree=/usr/lib/live --enable-caca --enable-skins --enable-skins2
 
--enable-alsa --disable-kde --enable-qt --enable-wxwindows --enable-ncurses --enable-release
 
  
[[User:J-b#My VLC|Here]] is another.
+
First, you need to install the GNU autotools (if you have not already done so), CMake, subversion, Git and a recent GNU/tar utility or equivalent.
 +
{{prompt|root}} apt-get install subversion yasm cvs cmake ragel
 +
 
 +
Then you can run:
 +
{{$}} cd contrib
 +
{{$}} mkdir native
 +
{{$}} cd native
 +
{{$}} ../bootstrap
 +
{{$}} make
 +
 
 +
That should download and build a lot of those libraries for you.  Unfortunately, given the large number of libraries and the variety of the platforms people build VLC for, it is not unlikely that you will hit an error while contribs are compiling. Thus, this approach is only recommended for experienced Unix compilers.
 +
 
 +
=== Regardless of the method ===
 +
In any case, some basic OS support libraries are not included and must really be installed through the packaging system in any case, notably [[ALSA]], [[PulseAudio]] and OpenGL.
 +
 
 +
== Configuration  ==
 +
<code>./configure</code> is used to check whether your system is able to compile VLC. Also you can choose the features in your build. As a reminder, this command will show the various options:
 +
{{$}} ./configure --help
 +
 
 +
For most users, <code>./configure</code> does not require any command-line options.
 +
 
 +
By default, features to be compiled are chosen automatically depending on what libraries are detected as available. If the contribs have been compiled first, the resulting VLC will be reasonably functional.
 +
 
 +
Note that libraries that are not in the default prefix, and not in vlc contribs, must be known to pkg-config in order for <code>./configure</code> to find them. Use ''PKG_CONFIG_PATH'' for this.
 +
 
 +
There are some features that are disabled (not compiled) by default. If you want them, they must be forced on by using configure flags. You can find a list of these features by searching for "disabled" in <code>./configure --help</code>.
 +
 
 +
=== Prefix  ===
 +
If you want to install VLC into another directory, run
 +
 +
{{$}} ./configure --prefix=/path/to/install/folder/
 +
 
 +
You can find example of configure in the [[Configure]] page of this wiki.
  
 
== Compilation ==
 
== Compilation ==
Compile VLC:
+
Compile VLC:  
  % make
+
  {{$}} make
 +
 
 +
You do not need to install VLC to use it. You can also simply run it from the build directory:
 +
{{prompt|root}} ./vlc
  
As root (type "su" to change to root account):
+
If you really want to install VLC to the system, run this as root:
  # make install
+
  {{prompt|root}} make install
 +
 
 +
You can uninstall later with this, but you need to keep the build tree untouched until then:
 +
{{prompt|root}} make uninstall
  
 
To remove files created during the compile (optional) type:
 
To remove files created during the compile (optional) type:
  % make clean
+
  {{$}} make clean
 +
 
 +
== Troubleshooting / common problems ==
 +
 
 +
=== Lua ===
 +
You may need to install Lua if you get "LUA byte compiler missing." message. You namely need to install "luac", the Lua byte compiler.
 +
 
 +
On Debian/Ubuntu:
 +
{{$}} sudo apt-get install lua5.1
 +
 
 +
On Fedora:
 +
{{$}} sudo yum install lua
 +
 
 +
=== XCB ===
 +
 
 +
VLC 1.1 and later requires XCB libraries to deal with X11 displays. Do not disable XCB or you will not get any video support!
 +
 
 +
To install these libraries run the following commands (Debian/Ubuntu):
 +
{{$}} sudo apt-get install libxcb-shm0-dev libxcb-xv0-dev libxcb-keysyms1-dev libxcb-randr0-dev libxcb-composite0-dev
 +
 
 +
Under Fedora:
 +
{{$}} sudo yum install libxcb-devel xcb-util-devel
  
 +
For OpenGL (Debian/Ubuntu only), you will additionally need XLib with XCB:
 +
{{$}} sudo apt-get install libx11-xcb-dev
  
== Notes ==
+
If your distribution provides a version of XLib without XCB, then this later package will not be available. So you will not be able to use OpenGL. Use XVideo instead.
=== Cygwin ===
 
Compiling on [[Win32CompileCygwin|Cygwin]] may be broken from time to time.
 
  
=== Debian ===
+
=== Compile fails after git pull ===
Debian users who want to compile VLC should install the packages below.
 
Note: if you just want to ''use'' VLC media player then simply install the package vlc (apt-get install vlc) - the unstable version is normally very up-to-date (and stable is, er, stable ;-)
 
* [http://packages.debian.org/unstable/libdevel/libavcodec-dev libavcodec-dev]
 
* [http://packages.debian.org/unstable/libdevel/libpostproc-dev libpostproc-dev]
 
* [http://packages.debian.org/unstable/libdevel/libmpeg2-4-dev libmpeg2-4-dev]
 
  
== Version ==
+
It is likely that the sources in the repository have changed significantly since they were last pulled, and a build system cache has gone out of date. Try the troubleshooting methods described in the [[Hacker_Guide/How_To_Write_a_Module#Module_load_troubleshooting|hacker guide for modules]].
This HOWTO has been originally written by [mailto:hartman_at_videolan_dot_org Derk-Jan Hartman].
 
It has been modified and updated by [[User:J-b| Jean-Baptiste Kempf]].
 
  
== See also ==
 
* http://www.slacky.it/repository/slackware/slackware-11.0/multimedia/vlc/0.8.6a/src/vlc.SlackBuild
 
 
[[Category:Building]]
 
[[Category:Building]]
 +
[[Category:GNU/Linux]]

Latest revision as of 17:06, 19 March 2022

Prepare your environment

VLC requires a C11 compiler, development headers and a toolchain.

gcc (version 4.9 or later) is recommended, but clang/LLVM are known to work as well.

If you build from the Git repositories, you will also need the GNU build system, also known as the "autotools" (autoconf, automake, libtool and gettext) to setup the Makefiles. Make sure they are up-to-date and usable for your system.

On Fedora:

$ sudo yum install git libtool pkgconfig

On Debian or Ubuntu:

$ sudo apt-get install git g++ make libtool automake autopoint pkg-config flex bison lua5.2

On Arch

$ sudo pacman -S base-devel git pkg-config autoconf automake

Get the source

Start by getting the source, using FTP for official releases, or using Git to track VLC development.

If you are using the Git development version, start by bootstrapping the source tree:

$ git clone git://git.videolan.org/vlc.git
$ cd vlc
$ ./bootstrap

Bootstrapping will fail if 'autotools' is missing or out-of-date.

If you are using an official release, download source code, extract the archive and go into the resulting VLC directory, e.g.:

$ wget ftp://ftp.videolan.org/pub/videolan/vlc/3.0.12/vlc-3.0.12.tar.xz
$ tar xvJf vlc-3.0.12.tar.xz
$ cd vlc-3.0.12

Get the third-party libraries

Now you can almost configure the VLC build. But first, you need to make sure that all the required dependencies are in place.

You must install and enable all the necessary underlying libraries. If you fail to install a required library, either the configure script or (more likely) you will end up with a crippled VLC program. Furthermore keep in mind that whilst build a program (in this case, VLC), you need to install the development packages (development header files and import libraries), not just the run-time libraries. On Debian/Ubuntu, the correct package names end with -dev. On RPM distributions, they usually end in -devel.

Be careful! If the libraries are not provided by your distribution, you may be better off linking VLC with them statically. See the "Contrib" method.

There are a several ways to get those libraries. You should use only one method at a time:

The preferred method

Installing the dependencies from the package or portage system is generally much easier and faster. However this only works if your distribution actually ships the necessary libraries. Otherwise, you may need to use the contribs method (see below). It is also possible to combine both methods, picking only the missing bits and pieces from contribs.

Debian

For example on Debian or Ubuntu:

$ sudo apt-get build-dep vlc

OpenSuSE

openSUSE users might have a look at the source-install (si) command in the zypper manpage:

$ sudo zypper si -d vlc

Note: To get the libraries, you must first add the VLC repositories to your system repositories. For example in openSUSE:

$ sudo zypper ar http://download.videolan.org/pub/vlc/SuSE/<openSUSEversion> VLC

You should replace <openSUSEversion> with the version of your system (12.1, 11.4, 11.3, 11.2 or 11.1)

The "Contrib" method

If your distribution does not provide the needed libraries or if you really need to link VLC statically, use the VLC contribs system, included in the VLC source.

First, you need to install the GNU autotools (if you have not already done so), CMake, subversion, Git and a recent GNU/tar utility or equivalent.

# apt-get install subversion yasm cvs cmake ragel

Then you can run:

$ cd contrib
$ mkdir native
$ cd native
$ ../bootstrap
$ make

That should download and build a lot of those libraries for you. Unfortunately, given the large number of libraries and the variety of the platforms people build VLC for, it is not unlikely that you will hit an error while contribs are compiling. Thus, this approach is only recommended for experienced Unix compilers.

Regardless of the method

In any case, some basic OS support libraries are not included and must really be installed through the packaging system in any case, notably ALSA, PulseAudio and OpenGL.

Configuration

./configure is used to check whether your system is able to compile VLC. Also you can choose the features in your build. As a reminder, this command will show the various options:

$ ./configure --help

For most users, ./configure does not require any command-line options.

By default, features to be compiled are chosen automatically depending on what libraries are detected as available. If the contribs have been compiled first, the resulting VLC will be reasonably functional.

Note that libraries that are not in the default prefix, and not in vlc contribs, must be known to pkg-config in order for ./configure to find them. Use PKG_CONFIG_PATH for this.

There are some features that are disabled (not compiled) by default. If you want them, they must be forced on by using configure flags. You can find a list of these features by searching for "disabled" in ./configure --help.

Prefix

If you want to install VLC into another directory, run

$ ./configure --prefix=/path/to/install/folder/

You can find example of configure in the Configure page of this wiki.

Compilation

Compile VLC:

$ make

You do not need to install VLC to use it. You can also simply run it from the build directory:

# ./vlc

If you really want to install VLC to the system, run this as root:

# make install

You can uninstall later with this, but you need to keep the build tree untouched until then:

# make uninstall

To remove files created during the compile (optional) type:

$ make clean

Troubleshooting / common problems

Lua

You may need to install Lua if you get "LUA byte compiler missing." message. You namely need to install "luac", the Lua byte compiler.

On Debian/Ubuntu:

$ sudo apt-get install lua5.1

On Fedora:

$ sudo yum install lua

XCB

VLC 1.1 and later requires XCB libraries to deal with X11 displays. Do not disable XCB or you will not get any video support!

To install these libraries run the following commands (Debian/Ubuntu):

$ sudo apt-get install libxcb-shm0-dev libxcb-xv0-dev libxcb-keysyms1-dev libxcb-randr0-dev libxcb-composite0-dev

Under Fedora:

$ sudo yum install libxcb-devel xcb-util-devel

For OpenGL (Debian/Ubuntu only), you will additionally need XLib with XCB:

$ sudo apt-get install libx11-xcb-dev

If your distribution provides a version of XLib without XCB, then this later package will not be available. So you will not be able to use OpenGL. Use XVideo instead.

Compile fails after git pull

It is likely that the sources in the repository have changed significantly since they were last pulled, and a build system cache has gone out of date. Try the troubleshooting methods described in the hacker guide for modules.