Apr 3, 2009

HOWTO: compiling VLC 0.9.9 + live555 + all major codecs on Ubuntu 8.10

VLC 0.9.9 was released a few days ago, so here's an updated version of my popular tutorial on how to build it from source on Ubuntu. As always, all comments welcome!

First of all, you need to build the latest ffmpeg and x264: please refer to this tutorial, which is still up to date.

Once you've done that, there are additional dependencies to take care of.

1) Installing libmad

MAD is a high-quality MPEG audio decoder. At the time of this writing, the latest version is 0.15.1b. Let's get the source, build it and install it:

ubuntu% wget http://ovh.dl.sourceforge.net/sourceforge/mad/libmad-0.15.1b.tar.gz
ubuntu% tar xvfz libmad-0.15.1b.tar.gz
ubuntu% cd libmad-0.15.1b
ubuntu% ./configure --prefix=/usr/local
ubuntu% make
ubuntu% sudo make install


[Updated on 2009/01/04] If you try to compile libmad with gcc 4.3, you will get the following error: cc1: error: unrecognized command line option "-fforce-mem". To correct this, just remove the -fforce-mem flags from the CFLAGS list in the Makefile.

2) Installing libdca

libdca is a free library for DTS audio. At the time of this writing, the latest version is 0.0.5. Let's get the source, build it and install it:

ubuntu% wget http://download.videolan.org/pub/videolan/libdca/0.0.5/libdca-0.0.5.tar.bz2
ubuntu% bzip2 -d
libdca-0.0.5.tar.bz2
ubuntu% tar xvf libdca-0.0.5.tar
ubuntu% cd libdca-0.0.5
ubuntu% ./configure --prefix=/usr/local
ubuntu% make
ubuntu% sudo make install

3) Installing libmpeg2

libmpeg2 is a free library for MPEG streams. At the time of this writing, the latest version is 2.0.5.1. Let's get the source, build it and install it:

ubuntu% wget http://libmpeg2.sourceforge.net/files/libmpeg2-0.5.1.tar.gz
ubuntu% tar xvfz libmpeg2-0.5.1.tar.gz
ubuntu% cd
libmpeg2-0.5.1
ubuntu% ./configure --prefix=/usr/local
ubuntu% make
ubuntu% sudo make install


4) Installing TagLib

TagLib is is a library for reading and editing the meta-data of several popular audio formats (MP3, FLAC, etc). At the time of this writing, the latest version is 1.5. Let's get the source, build it and install it:

ubuntu% wget http://developer.kde.org/~wheeler/files/src/taglib-1.5.tar.gz
ubuntu% tar xvfz taglib-1.5.tar.gz
ubuntu% ./configure --prefix=/usr/local
ubuntu% make
ubuntu% sudo make install


5) Installing live555

live555 is a set of libraries for multimedia streaming (RTP/RTCP, RTSP, SIP).

ubuntu% wget http://www.live555.com/liveMedia/public/live555-latest.tar.gz
ubuntu% tar xvfz live555-latest.tar.gz
ubuntu% cd live
ubuntu% ./genMakefiles linux
ubuntu% make

There is no installation procedure for live555. You have to copy the full directory somewhere safe, like /usr/lib.

ubuntu% sudo cp -r live /usr/lib

6) Installing everything else

Now, let's use APT to fetch all the remaining libraries needed by VLC, as well as the Qt4 packages required by the GUI:

ubuntu% sudo apt-get install libavc1394-dev libraw1394-dev libdc1394-dev libdvdread-dev libdvdnav-dev libdvdcss2-dev libfaad-dev libtwolame-dev liba52-dev libvcdinfo-dev libiso9660-dev libcddb2-dev libflac-dev libschroedinger-dev liba52-dev libogg-dev libvorbis-dev liblua5.1-0-dev libgnomevfs2-dev libtag1-dev libqt4-dev

That should really be it...

7) Fetching VLC

Stable sources can be downloaded as a tarball from the VLC download page. At the time of this writing, the latest version is VLC 0.9.9. If you want to try development snapshots, be my guest but YMMV!

ubuntu% wget http://download.videolan.org/pub/videolan/vlc/0.9.9/vlc-0.9.9.tar.bz2
ubuntu% bzip2 -d vlc-0.9.9.tar.bz2
ubuntu% tar xvf vlc-0.9.9.tar


8) Adding x264 and live555 to the mix

For the sake of convenience, let's copy the directories into the VLC tree:

ubuntu% cd vlc-0.9.9
ubuntu% cp -r $YOUR_X264_BUILD_DIR extras
ubuntu% cp -r $YOUR_LIVE555_BUILD_DIR extras
ubuntu% ls extras
analyser buildsystem contrib live misc package x264

9) Building VLC

Let's go! Don't forget to check your configure output for possible errors.

ubuntu% ./configure --prefix=/usr/local --with-x264-tree=extras/x264 --with-live555-tree=extras/live --enable-release --enable-switcher --enable-shout --enable-dc1394 --enable-dv --enable-dvdread --enable-v4l --enable-pvr --enable-gnomevfs --enable-vcdx --enable-faad --enable-twolame --enable-real --enable-realrtsp --enable-flac --enable-tremor --enable-tarkin --enable-theora --enable-ogg --enable-vorbis --enable-a52 --enable-gnomevfs --enable-dca
Lots of output removed
You can tune the compiler flags in vlc-config.
To build vlc and its plugins, type `./compile' or `make'.

All right, let's run make and get some coffee while VLC is building:

ubuntu% make
lots of output removed
make[2]: Leaving directory `/home/julien/tmp/vlc-0.9.9'
make[1]: Leaving directory `/home/julien/tmp/vlc-0.9.9.'

We're done! Let's check our new VLC before we install it.

7) Checking VLC

ubuntu% ./vlc --version
VLC media player 0.9.9 Grishenko
[00000001] main libvlc debug: VLC media player - version 0.9.9 Grishenko - (c) 1996-2009 the VideoLAN team
[00000001] main libvlc debug: libvlc was configured with ./configure '--prefix=/usr/local' '--with-x264-tree=extras/x264' '--with-live555-tree=extras/live' '--enable-release' '--enable-switcher' '--enable-shout' '--enable-dc1394' '--enable-dv' '--enable-dvdread' '--enable-v4l' '--enable-pvr' '--enable-vcdx' '--enable-faad' '--enable-twolame' '--enable-real' '--enable-realrtsp' '--enable-flac' '--enable-tremor' '--enable-tarkin' '--enable-theora' '--enable-ogg' '--enable-vorbis' '--enable-a52' '--enable-gnomevfs' '--enable-dca'
[00000001] main libvlc debug: translation test: code is "C"
VLC version 0.9.9 Grishenko
Compiled by julien@ubuntu.
Compiler: gcc version 4.3.2 (Ubuntu 4.3.2-1ubuntu12)
This program comes with NO WARRANTY, to the extent permitted by law.
You may redistribute it under the terms of the GNU General Public License;
see the file named COPYING for details.
Written by the VideoLAN team; see the AUTHORS file.


Looks good. You can verify that your favorite codecs are supported with 'vlc --list'.

I now declare this a good build :) Let's install it:

ubuntu% sudo make install

We're done. Now you can enjoy all your media files with a single player!

12 comments:

  1. Hi, I have really enjoyed your tutorials. They are so very well laid out, clear, and logical.

    I made it all the way to MAKE... and got the following error:

    libtool: compile: gcc -std=gnu99 -DHAVE_CONFIG_H -I. -I../.. -I../../include -I../../include -DSYS_LINUX -I/usr/local/include -D_FILE_OFFSET_BITS=64 -D__USE_UNIX98 -D_LARGEFILE64_SOURCE -D_REENTRANT -D_THREAD_SAFE -DHAVE_RELEASE -D__LIBVLC__ -D__PLUGIN__ -I/root/src/vlc-0.9.9/extras/x264 -DMODULE_NAME=x264 -DMODULE_NAME_IS_x264 -DMODULE_STRING=\"x264\" -O3 -ffast-math -funroll-loops -mtune=athlon64 -fomit-frame-pointer -I/usr/local/include -Wall -Wextra -Wsign-compare -Wundef -Wpointer-arith -Wbad-function-cast -Wcast-align -Wwrite-strings -Wmissing-prototypes -Wvolatile-register-var -MT libx264_plugin_la-x264.lo -MD -MP -MF .deps/libx264_plugin_la-x264.Tpo -c x264.c -fPIC -DPIC -o .libs/libx264_plugin_la-x264.o
    x264.c: In function ‘Open’:
    x264.c:962: error: ‘x264_param_t’ has no member named ‘b_pre_scenecut’
    make[5]: *** [libx264_plugin_la-x264.lo] Error 1
    make[5]: Leaving directory `/root/src/vlc-0.9.9/modules/codec'
    make[4]: *** [all-recursive] Error 1
    make[4]: Leaving directory `/root/src/vlc-0.9.9/modules/codec'
    make[3]: *** [all] Error 2
    make[3]: Leaving directory `/root/src/vlc-0.9.9/modules/codec'
    make[2]: *** [all-recursive] Error 1
    make[2]: Leaving directory `/root/src/vlc-0.9.9/modules'
    make[1]: *** [all-recursive] Error 1
    make[1]: Leaving directory `/root/src/vlc-0.9.9'
    make: *** [all] Error 2

    ReplyDelete
  2. Hi Michael,

    yep, same here. Looks like the latest x264 (x264 0.67.1139 1024283) breaks the vlc build. Until this is fixed, I would recommend using an older x264 snapshot. This definitely worked when I wrote the article on April 3rd ;)

    ReplyDelete
  3. Yes sir... I found where the latest x264 was changed only 4 days ago and guess what was changed... something to do with "pre_scenecut" according to the git logs.

    I'm off to find an ealier version and will report back later. Thanks!

    Michael

    ReplyDelete
  4. Julien,

    Do you remember which snapshot you used? I've tried several earlier versions (back through x264-snapshot-20090330-2245.tar.bz2) but keep getting the same error.

    I am compiling on Ubuntu 8.10 Intrepid server, AMD64.

    ReplyDelete
  5. Actually, I've been using the same x264 snapshot that I used for the VLC 0.9.8 tutorial :) This one dates back to December 2008. Sorry about the confusion!

    ReplyDelete
  6. @Julien :

    Its out a new release of VLC , the 0.9.9a.

    This release does not have the error with x264 with recent snapshots :)

    Thanks for your guide.

    ReplyDelete
  7. thanks alot for the installation routine, this also worked with my 8.04 hardy. Your tutorials are as great as ever.

    0.99a did fix the existing problem just as the previous posters stated

    ReplyDelete
  8. Thank you for the followup tips, but it was a no-go. I grabbed vlc-0.9.9a and used the old x264 snapshot from 01012009 and got the following error:

    /usr/bin/ld: /root/workspace/build/vlc-0.9.9a/extras/live/UsageEnvironment/libUsageEnvironment.a: relocation R_X86_64_32S against `vtable for UsageEnvironment' can not be used when making a shared object; recompile with -fPIC
    /root/workspace/build/vlc-0.9.9a/extras/live/UsageEnvironment/libUsageEnvironment.a: could not read symbols: Bad value
    collect2: ld returned 1 exit status
    make[5]: *** [liblive555_plugin.la] Error 1
    make[5]: Leaving directory `/root/workspace/build/vlc-0.9.9a/modules/demux'
    make[4]: *** [all-recursive] Error 1
    make[4]: Leaving directory `/root/workspace/build/vlc-0.9.9a/modules/demux'
    make[3]: *** [all] Error 2
    make[3]: Leaving directory `/root/workspace/build/vlc-0.9.9a/modules/demux'
    make[2]: *** [all-recursive] Error 1
    make[2]: Leaving directory `/root/workspace/build/vlc-0.9.9a/modules'
    make[1]: *** [all-recursive] Error 1
    make[1]: Leaving directory `/root/workspace/build/vlc-0.9.9a'
    make: *** [all] Error 2

    -------
    Everything I complied had -fPIC set either manually when suggested by a tutorial or commenter, or automatically during a "./configure" command.

    If it helps, here's my system info:
    Ubuntu 8.10 Intrepid Server - kernel 2.6.27-11-server on AMD64 architecture.

    -Michael

    ReplyDelete
  9. Success!

    I had to add -fPIC to all the Makefiles generated by "./genMakefiles linux" just before compiling Live555.

    In each Makefile, the option -fPIC was added after the last option, at the very end of "COMPILE_OPTS ="

    Thanks again for the tutorials and for everyone's help!

    -Michael

    ReplyDelete
  10. Well my joy was short-lived. When trying to run vlc, I get this:

    vlc: error while loading shared libraries: libvlc.so.2: cannot open shared object file: No such file or directory

    Sorry to muddle up your blog post with all these comments.

    ReplyDelete
  11. Hi Michael,

    do you have this library in /usr/local/lib ? did you update LD_LIBRARY PATH to include /usr/local/lib ?

    Cheers,

    Julien

    ReplyDelete
  12. I'm having the same problem. I'm building vlc from the latest git, and get this error:

    gcc -std=gnu99 -shared .libs/libx264_plugin_la-x264.o -Wl,--whole-archive ../../compat/.libs/libcompat.a -Wl,--no-whole-archive -Wl,--rpath -Wl,/home/sysadmin/downloads/vlc/build/src/.libs -L/usr/local/lib -lx264 -lpthread -lm ../../src/.libs/libvlccore.so -mtune=athlon64 -Wl,-Bsymbolic -Wl,-soname -Wl,libx264_plugin.so -o .libs/libx264_plugin.so
    /usr/bin/ld: /usr/local/lib/libx264.a(common.o): relocation R_X86_64_32 against `a local symbol' can not be used when making a shared object; recompile with -fPIC

    Does that mean I should rebuild libx264 with -fPIC?

    in my system /usr/local/lib is part of the ld.so.conf

    ReplyDelete