Win32Compile

From VideoLAN Wiki
Revision as of 13:08, 13 June 2010 by J-b (talk | contribs)
Jump to navigation Jump to search

Before you start

One common desire that leads people to want to rebuild VLC is to "rebuild a debug version" or "add printf()s", but this is not strictly necessary, as VLC includes a debug logging feature by default. If you are using a binary release (or have already built VLC), just run 'vlc.exe' and select "Messages..." from the "Tools" menu.

You can also run VLC from the Windows command-line interpreter, cmd.exe (a.k.a. "DOS window"), in which case you'll be able to use the command-line arguments. You can obtain a list of these command line arguments by typing 'vlc --help' or 'vlc --help --advanced'.

To store a debug log of the current VLC session, you can use 'vlc -vvv --extraintf=logger'. You will end-up with a vlc-log.txt file in your current directory.

Building VLC from source

If you want to build VLC from source, you have several choices:

Method Documentation Notes
Cross-compile with Mingw32 on Linux None Preferred method (uses cross compilation)
Native-compile with MSYS+MINGW Win32CompileMSYSNew Preferred native compilation method. MSYS is a minimal build environment to compile Unixish projects under Microsoft Windows. It provides all the commonly-required Unix tools (like sh, gmake, and so forth).
Native-compile with Cygwin Win32CompileCygwinNew OUTDATED native compilation method
Native-compile with Microsoft Visual C++ None Not advised.

Even though VLC includes some MSVC project files, this method is advised only if you just want to experiment/play with some basic functionality in VLC. VLC depends on a lot of third-party libraries and building them in MSVC is inconvenient (and in some cases, impossible).
If you want to run VLC under the MSVC debugger, use --fast-mutex --win9x-cv-method=1 because the debugger usually loses signals sent by PulseEvent().

Obtaining the build tools

Each build method requires its own toolchain:

Method Notes
Cross-compile with mingw32 on GNU/Linux
  • Debian/Ubuntu users can apt-get install mingw32 mingw32-binutils, however building FFmpeg now requires mingw32-runtime >= 3.15 and w32api >= 3.13 so these will have to be updated manually.
  • Gentoo users can emerge crossdev && crossdev mingw32
  • Other systems may attempt http://www.mingw.org/wiki/LinuxCrossMinGW
Native-compile with MSYS+MINGW Read the documentation
Native-compile with Cygwin Read the documentation

3rd party libraries.

VLC modules requires numerous open source projects to work (like AC3 audio decoding or MPEG-4 video decoding).

If you feel you must build these libraries from source, go to extras/contrib and read the README.

If you want to save yourself a lot of time and energy, use the pre-built versions of these libraries. You may download them from http://people.videolan.org/~jb/Contribs/, named in fashion of contrib-yyyymmdd-win32-version-bin-gcc-gccversion-only.tar.bz2.

Install the pre-built libraries into the standard directories (/usr/win32/*) by using

tar jxf contrib-20061122-win32-bin-gcc-3.4.5-only.tar.bz2 -C /

(Note the "-C /"!)

Configuring the build

Once you've got all the files you need in place, you need to configure the build with the configure script. In the following examples, assume that the third-party libraries are installed in $CONTRIBS. If installed in the Cygwin standard directories, use export CONTRIBS=/usr/win32. Otherwise use export CONTRIBS=/cygdrive/d/VLC.

If you are cross-compiling under GNU/Linux, you can use something along these lines:

 ./bootstrap && \
 export PKG_CONFIG_LIBDIR=$CONTRIBS/lib/pkgconfig PKG_CONFIG_PATH=$CONTRIBS/lib/pkgconfig \
 CPPFLAGS="-I$CONTRIBS/include -I$CONTRIBS/include/ebml" CXXCPP=i586-mingw32msvc-cpp \
 LDFLAGS=-L$CONTRIBS/lib \
 CC=i586-mingw32msvc-gcc CXX=i586-mingw32msvc-g++
 ./configure --host=i586-mingw32msvc --build=i386-linux \
     --disable-Gtk \
     --enable-Nls --enable-Sdl --with-sdl-config-path=$CONTRIBS/bin \
     --enable-Ffmpeg --with-ffmpeg-mp3lame --with-ffmpeg-Faac \
     --with-ffmpeg-Zlib --enable-Faad --enable-Flac --enable-Theora \
     --with-Wx-config-path=$CONTRIBS/bin \
     --with-Freetype-config-path=$CONTRIBS/bin \
     --with-Fribidi-config-path=$CONTRIBS/bin \
     --with-Libgcrypt-prefix=$CONTRIBS \
     --enable-Live555 --with-live555-tree=$CONTRIBS/live.com \
     --enable-Caca --with-caca-config-path=$CONTRIBS/bin \
     --with-Xml2-config-path=$CONTRIBS/bin \
     --with-Dvdnav-config-path=$CONTRIBS/bin \
     --disable-Cddax --disable-Vcdx --enable-Goom \
     --enable-Twolame --enable-Dvdread \
     --enable-Debug

If you are using cygwin, you can build VLC with or without the POSIX emulation layer. Without is usually better and with POSIX emulation hasn't been tested in over a year. So to build without the emulation layer, use something like this:

 ./bootstrap && \
 export PKG_CONFIG_PATH=$CONTRIBS/lib/pkgconfig \
 CPPFLAGS="-I$CONTRIBS/include -I$CONTRIBS/include/ebml" CXXCPP=$CPPFLAGS \
 LDFLAGS=-L$CONTRIBS/lib \
 CC='gcc -mno-cygwin' CXX='g++ -mno-cygwin' \
 ./configure \
     --disable-gtk \
     --enable-nls --enable-sdl --with-sdl-config-path=$CONTRIBS/bin \
     --enable-ffmpeg --with-ffmpeg-mp3lame --with-ffmpeg-faac \
     --with-ffmpeg-zlib --enable-faad --enable-flac --enable-theora \
     --with-wx-config-path=$CONTRIBS/bin \
     --with-freetype-config-path=$CONTRIBS/bin \
     --with-fribidi-config-path=$CONTRIBS/bin \
     --enable-live555 --with-live555-tree=$CONTRIBS/live.com \
     --enable-caca --with-caca-config-path=$CONTRIBS/bin \
     --with-xml2-config-path=$CONTRIBS/bin \
     --with-dvdnav-config-path=$CONTRIBS/bin \
     --disable-cddax --disable-vcdx --enable-goom \
     --enable-twolame --enable-dvdread \
     --enable-debug

If you want to use the emulation layer, then just omit CFLAGS and CXXFLAGS. You're on your own, though.

If you are compiling with MSYS/MINGW, then you can use something along those lines:

 ./bootstrap && \
 export PKG_CONFIG_PATH=$CONTRIBS/lib/pkgconfig \
 CPPFLAGS="-I$CONTRIBS/include -I$CONTRIBS/include/ebml" CXXCPP=$CPPFLAGS \
 LDFLAGS=-L$CONTRIBS/lib \
 ./configure \
     --disable-gtk \
     --enable-nls --enable-sdl --with-sdl-config-path=$CONTRIBS/bin \
     --enable-ffmpeg --with-ffmpeg-mp3lame --with-ffmpeg-faac \
     --with-ffmpeg-zlib --enable-faad --enable-flac --enable-theora \
     --with-wx-config-path=$CONTRIBS/bin \
     --with-freetype-config-path=$CONTRIBS/bin \
     --with-fribidi-config-path=$CONTRIBS/bin \
     --enable-caca --with-caca-config-path=$CONTRIBS/bin \
     --with-xml2-config-path=$CONTRIBS/bin \
     --with-dvdnav-config-path=$CONTRIBS/bin \
     --disable-cddax --disable-vcdx --enable-goom \
     --enable-twolame --enable-dvdread \
     --disable-Mkv \
     --enable-debug

If you have used the "extras/contrib" way, you don't need to specify CFLAGS, LDFLAGS and --with-foo-config-path=.

./bootstrap && \
 ./configure \
     --disable-gtk \
     --enable-nls --enable-sdl \
     --enable-ffmpeg --enable-faad --enable-flac --enable-theora \
     --disable-cddax --disable-vcdx --enable-goom \
     --enable-twolame --enable-dvdread \
     --enable-mkv --enable-caca --enable-live555\
     --enable-debug

See './configure --help' for more information.

Building VLC

Once configured, to build VLC, just run 'make'.

Once the compilation is done, you can either run VLC directly from the source tree or you can build self-contained VLC packages with the following make rules:

Command Description
make package-win32-base Creates a subdirectory named vlc-x.x.x with all the binaries 'stripped' (that is, smallest size, unusable with a debugger)
make package-win32-zip Same as above but will package the directory in a zip file.
make package-win32 Same as above but will also create an auto-installer package. You must have NSIS installed in its default location for this to work.

Well done—you're ready to use VLC!