Difference between revisions of "Win32Compile"

From VideoLAN Wiki
Jump to navigation Jump to search
 
(164 intermediate revisions by 41 users not shown)
Line 1: Line 1:
From http://developers.videolan.org/vlc/vlc/INSTALL.win32
+
<big>'''WARNING: This page is deprecated, for updated instructions please follow: https://code.videolan.org/videolan/vlc/-/blob/master/doc/BUILD-win32.md'''</big>
  
$Id: INSTALL.win32 15707 2006-05-22 09:42:08Z xtophe $
+
This page will help you to compile {{VLC}} for [[Windows]].
INSTALL file for the Windows9x/Me/NT4/2k/XP version of the VLC media player
 
  
==Before you start==
+
== Building Methods ==
  
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 <CODE>'vlc.exe'</CODE> and select "Messages..." from the "View" menu.
+
If you want to build VLC from source, you have several choices:  
 
 
You can also run VLC from the Windows command-line interpreter, <CODE>cmd.exe</CODE> (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 <CODE>'vlc --help'</CODE> or <CODE>'vlc --help --advanced'</CODE>.
 
 
 
To store a debug log of the current VLC session, you can use <CODE>'vlc -vvv --extraintf=logger'</CODE>. You will end-up with a <CODE>vlc-log.txt</CODE> file in your current directory.
 
 
 
==Building VLC from source==
 
 
 
If you want to build VLC from source, you have several choices:
 
  
 
{| class="wikitable"
 
{| class="wikitable"
! Method
 
! Documentation
 
! Notes
 
 
|-
 
|-
| Cross-compile with mingw32 on GNU/Linux
+
! Method
| None
+
! Documentation
| '''Preferred''' cross-compilation method
+
! Notes
 
|-
 
|-
| Native-compile with [http://www.cygwin.com Cygwin]
+
| '''MinGW on Linux'''
| [[Win32CompileCygwin]]
+
| [[#Obtaining_the_toolchain|Obtaining the toolchain]]
| '''Preferred''' native compilation method
+
| '''Preferred''' method involving cross-compilation from Linux. On computers running Microsoft Windows, a virtual machine is necessary to run Linux.
 
|-
 
|-
| Native-compile with [http://www.mingw.org MSYS+MINGW]
+
| '''[http://www.mingw.org MSYS+MinGW]''' on Windows
| [[Win32CompileMSYS]]
+
| [[Win32CompileMSYS|Compile with MSys]]  
| 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). Please note that the gettext utilities are not included in the default MSYS/MINGW packages so you won't be able to build VLC with i18n support.
+
| '''Native''' compilation method. MSYS is a minimal build environment to compile Unix-style projects directly on Microsoft Windows. This is '''not officially supported''' by VideoLAN. Best of luck.
 
|-
 
|-
| Native-compile with Microsoft Visual C++
+
| '''Cygwin''' on Windows
| None
+
| [[Win32CompileCygwinNew|Compile with Cygwin]]
|
+
| Cygwin method. Cygwin emulates a POSIX environment to compile on Microsoft Windows. This is '''error'''-prone and '''slow''' and therefore not recommended.
'''Not advised.''' <P>
 
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). <BR>
 
If you want to run VLC under the MSVC debugger, use <CODE>--fast-mutex --win9x-cv-method=1</CODE> because the debugger usually loses signals sent by PulseEvent().
 
 
|}
 
|}
  
==Obtaining the build tools==
+
== Obtaining the cross-compilation toolchain  ==
 +
All this howto is focused on  '''Debian/Ubuntu'''. For other distribution, please find the related package names, but they should be very similar.
  
Each build method requires its own toolchain:
+
'''Ubuntu 14.04''' is too old to compile VLC.
  
{| class="wikitable"
+
=== Host triplet ===
! Method
+
A number of commands below include the toolchain identifier, called the ''host triplet''.
! Notes
+
 
|-
+
This value is '''essential''': it instructs the build system to use the correct toolchain and compile the program for Windows.
| Cross-compile with mingw32 on GNU/Linux
+
Without the value, the build system will perform a native compilation for Linux (or whatever your computer runs). With an incorrect value, the build will fail.
|
+
 
*Debian/Ubuntu users can <CODE>apt-get install mingw32 mingw32-binutils</CODE>
+
The exact value depends on your installation of the toolchain.
*Gentoo users can <CODE>emerge xmingw-gcc xmingw-binutils</CODE>
+
 
*Other systems may attempt http://www.mingw.org/mingwfaq.shtml#faq-cross
+
Notably on Debian/Ubuntu, these values must be used:
|-
+
* ''i686-w64-mingw32'' for Windows 32-bits, using the Mingw-w64 toolchain
| Native-compile with [http://www.cygwin.com Cygwin]
+
* ''x86_64-w64-mingw32'' for Windows 64-bits, using the Mingw-w64 toolchain
| Install Cygwin, adding the optional <CODE>gcc-g++</CODE>, <CODE>gcc-mingw</CODE>, <CODE>mingw-runtime</CODE> and <CODE>win32-api</CODE> packages from the <CODE>Devel</CODE> category.
+
 
|-
+
Please make sure that you replace the keywords ''HOST-TRIPLET'' with either ''i686-w64-mingw32'' or ''x86_64-w64-mingw32'' adapted to your target Windows version (32-bit or 64-bit, respectively)
| Native-compile with [http://www.mingw.org MSYS+MINGW]
+
 
| Download and install the latest MSYS, MSYS-DTK, and MINGW from http://www.mingw.org/download.shtml. Begin with the MSYS auto-installer, then extract MINGW into <CODE>C:\MSYS\1.0\MINGW</CODE>. You also have to remember to remove the <CODE>make</CODE> utility included with MINGW as it conflicts with the one from MSYS (just rename or remove <CODE>C:\MSYS\1.0\MINGW\BIN\MAKE.EXE</CODE>).
+
=== Compiler and binary toolchain ===
|}
+
 
 +
==== Mingw-w64 ====
 +
To compile VLC for Windows (32-bits or 64-bits), the Mingw-w64 toolchain is required:
 +
 
 +
For the 32-bit version, run this:
 +
{{prompt|root}} apt-get install gcc-mingw-w64-i686 g++-mingw-w64-i686 mingw-w64-tools
 +
 
 +
For the 64-bit version, this becomes:
 +
{{prompt|root}} apt-get install gcc-mingw-w64-x86-64 g++-mingw-w64-x86-64 mingw-w64-tools
 +
 
 +
'''NB:''' you need mingw-w64 version 5.0.1 to compile it.
 +
 
 +
=== Development tools ===
 +
You will also need:
 +
* lua (5.2)
 +
* all autotools: libtool, automake, autoconf, autopoint, make, gettext, pkg-config
 +
* qt4-dev-tools, qt5-default (or qt4-default if qt plugin build fails)
 +
* git, subversion cmake, cvs if you want to rebuild contribs
 +
* wine-dev for creating Win32 packages
 +
* zip [for creating .zip package], p7zip [for .7z package], nsis [for .exe auto-installer], bzip2 [for 'make prebuild]
 +
 
 +
'''Run:'''
 +
{{prompt|root}} apt-get install lua5.2 libtool automake autoconf autopoint make gettext pkg-config
 +
{{prompt|root}} apt-get install qt4-dev-tools qt5-default git subversion cmake cvs
 +
{{prompt|root}} apt-get install wine64-development-tools libwine-dev zip p7zip nsis bzip2
 +
{{prompt|root}} apt-get install yasm ragel ant default-jdk protobuf-compiler dos2unix
 +
 
 +
== Get the source code ==
 +
{{$}} git clone https://code.videolan.org/videolan/vlc.git vlc
 +
 
 +
See [[Git]] for more information.
 +
 
 +
== Go into the VLC directory ==
 +
{{$}} cd vlc
 +
 
 +
== Prepare [[Contrib Status|3rd party libraries]]  ==
 +
 
 +
VLC depends on a sizable number of third party libraries. Before compiling VLC, you need to obtain compiled versions of those. There are two ways to achieve that:
 +
* The ''prebuilt'' approach is much faster and easier, but only works with a narrow set of VLC versions.
 +
* The ''manual build'' approach takes a lot of time and disk space, and somewhat error-prone.
 +
 
 +
Please note that the prebuilt library versions are intended for the latest current ''stable release'' of VLC. It is not compatible with old VLC versions, nor with newer or future versions.
 +
 
 +
At the time of writing (late 2016), the prebuilt libraries work with VLC 2.2.x '''only'''. To compile the VLC 3.0.x development branch, '''DO NOT USE''' the prebuilt libraries.
 +
 
 +
=== Prebuilt (fast) ===
 +
  {{$}} mkdir -p contrib/win32
 +
  {{$}} cd contrib/win32
 +
  {{$}} ../bootstrap --host=HOST-TRIPLET
 +
  {{$}} make prebuilt
 +
 
 +
=== Manually built (slow) ===
 +
Or, if you want to compile the contribs yourself and are feeling adventurous and have lots of time to burn:
 +
  {{prompt|root}} apt-get install subversion yasm cvs cmake ragel autopoint
 +
 
 +
  {{$}} mkdir -p contrib/win32
 +
  {{$}} cd contrib/win32
 +
  {{$}} ../bootstrap --host=HOST-TRIPLET
 +
  {{$}} make fetch
 +
  {{$}} make
  
==Saving time by using pre-built libraries==
+
=== Linux 64-bit ===
  
VLC requires other open source projects to provide some features (like AC3 audio decoding and MPEG-4 video decoding). A complete list of required libraries from these projects can be found at http://developers.videolan.org/vlc/.  Depending on your needs, you must either build your own versions of these libraries or use VLC's convenient pre-built versions.
+
If you are on Linux '''64-bit''', you '''SHOULD''' remove some files, or install the lib32 packages (ia32-libs, multilibs, etc...)
  
If you feel you must build these libraries from source, the blessed source code may be found at http://download.videolan.org/pub/testing/contrib/. An automated way of building the contrib libraries is provided in extra/contrib. It will download, configure, and build the libraries. See the extras/contrib/README for more info.
+
  {{$}} rm -f ../i686-w64-mingw32/bin/moc ../i686-w64-mingw32/bin/uic ../i686-w64-mingw32/bin/rcc
  
If you want to save yourself time and energy by using the pre-built versions of these libraries, you may download them from http://download.videolan.org/pub/testing/win32/ . The pre-built versions will ''only work with MINGW or Cygwin''.  Note that the version you download must match that of the MINGW compiler, <CODE>i586-mingw32msvc-gcc</CODE>, which you can verify by typing <CODE>'i586-mingw32msvc-gcc --ver'</CODE>.
+
=== Fix your contrib path ===
  
There are two installation strategies:
+
If your host triplet is not '''i686-w64-mingw32''' (you are ''not'' compiling for Debian or Ubuntu), create a symlink to contribs:
 +
{{$}} ln -sf ''''HOST-TRIPLET'''' ../i686-w64-mingw32
 +
Notice that there is no <code>../</code> before the host triplet. This is intentional, and if done properly, you should see a functioning symbolic link created in the parent directory (try <code>ls -l ..</code> and you should see <code>i686-w64-mingw32 -> x86_64-w64-mingw32/</code>).
  
{| class="wikitable"
+
=== Go Back ===
  ! Location
 
! Command
 
! Advantages
 
! Disadvantages
 
|-
 
| Install the pre-built libraries into the Cygwin standard directories (/usr/win32/*)
 
| <CODE>tar jxf contrib-20061122-win32-bin-gcc-3.4.5-only.tar.bz2 -C /</CODE> (Note the <CODE>"-C /"</CODE>!)
 
|
 
*Shorter initial setup time
 
|
 
*May conflict with other headers/libraries in the standard directories
 
*Difficult to get rid of if you want to free up space or to upgrade to the next version of the pre-built libraries (Installing over the top of older versions is highly discouraged!)
 
|-
 
| Install the pre-built libraries into a project-specific directory (e.g., <CODE>D:\VLC</CODE>)
 
| <CODE>tar jxf contrib-20061122-win32-bin-gcc-3.4.5-only.tar.bz2 -C /cygdrive/d/VLC</CODE>
 
|
 
*No conflicts with other projects built under Cygwin
 
*Easy to get rid of if you want to free up space or to upgrade to the next version of the pre-built libraries
 
*For multi-person projects, easy to put under revision control to ensure all project members are using the correct pre-built versions
 
|
 
*Requires that you set <CODE>CPPFLAGS</CODE>, <CODE>LDFLAGS</CODE> appropriately when building
 
*Requires that you modify hard-coded paths in the pre-built libraries (see below)
 
|}
 
  
If installing into a project-specific directory, you must modify some hard-coded paths in the pre-build libraries as follows:
+
Go back to the VLC source directory:  
<PRE>
 
CONTRIBS=/cygdrive/d/VLC
 
for file in $CONTRIBS/bin/*-config $CONTRIBS/lib/*.la ; do
 
perl -i.bak -p -e 's|/usr/win32|$ENV{"CONTRIBS"}|g' $file
 
done
 
</PRE>
 
  
==Configuring the build==
+
  {{$}} cd -
  
Once you've got all the files you need in place, you need to configure the build with the <CODE>configure</CODE> script.  In the following examples, assume that the third-party libraries are installed in <CODE>$CONTRIBS</CODE>. If installed in the Cygwin standard directories, use <CODE>export CONTRIBS=/usr/win32</CODE>. Otherwise use <CODE>export CONTRIBS=/cygdrive/d/VLC</CODE>.
+
== Configuring the build  ==
  
If you are cross-compiling under GNU/Linux, you can use something along these lines:
+
=== Bootstrap ===
 +
First, prepare the tree:
 +
  {{$}} ./bootstrap
  
  ./bootstrap && \
+
=== Configure ===
  export PKG_CONFIG_PATH=$CONTRIBS/lib/pkgconfig \
+
Then you can to configure the build with the <code>./configure</code> script.  
  CPPFLAGS="-I$CONTRIBS/include -I$CONTRIBS/include/ebml" CXXCPP=$CPPFLAGS \
 
  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 \
 
      --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:
+
Create a subfolder:
 +
  {{$}} mkdir win32 && cd win32
  
  ./bootstrap && \
+
Set your PKG_CONFIG_LIBDIR (Adapt the path to reflect your local setup)
   export PKG_CONFIG_PATH=$CONTRIBS/lib/pkgconfig \
+
   {{$}} export PKG_CONFIG_LIBDIR=$HOME/vlc/contrib/HOST-TRIPLET/lib/pkgconfig
  CPPFLAGS="-I$CONTRIBS/include -I$CONTRIBS/include/ebml" CXXCPP=$CPPFLAGS \
+
   {{$}} export PKG_CONFIG_PATH_CUSTOM=$PKG_CONFIG_LIBDIR (for Archlinux only)
   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 <CODE>CFLAGS</CODE> and <CODE>CXXFLAGS</CODE>. You're on your own, though.
+
Execute the build configuration script:
 +
{{$}} ../extras/package/win32/configure.sh --host=HOST-TRIPLET --build=x86_64-pc-linux-gnu
  
If you are compiling with MSYS/MINGW, then you can use something along those lines:
+
'''N.B.''':
  ./bootstrap && \
+
Use the host and build tuples respectively corresponding to '''your''' cross-compilation toolchain and build system respectively. The example above assumes you are compiling for ''Windows'' OS and ''Intel 686'' architecture, and the build system is ''GNU/Linux'' OS and ''x86 64-bits'' architecture. See [[#Host_triplet|above]] for list of common values.
  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 <CODE>CFLAGS</CODE>, <CODE>LDFLAGS</CODE> and <CODE>--with-foo-config-path=</CODE>.
+
Also, if you have a problem here (such as an error about Library dvdread), see the [[{{TALKPAGENAME}}|Talk]] page.
./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 <CODE>'./configure --help'</CODE> for more information.
+
Alternatively, you can run configure manually:
 +
{{$}} ../configure --host=HOST-TRIPLET --build=x86_64-pc-linux-gnu
 +
See <code>'../configure --help'</code> for more information.
  
==Building VLC==
+
== Building VLC ==
  
Once configured, to build VLC, just run <CODE>'make'</CODE>.
+
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 <CODE>make</CODE> rules:
+
== Packaging VLC ==
 +
Once the compilation is done, you can build self-contained VLC packages with the following <code>make</code> rules:  
  
 
{| class="wikitable"
 
{| class="wikitable"
! Command
 
! Description
 
 
|-
 
|-
| <CODE>make package-win32-base</CODE>
+
! Command
| Creates a subdirectory named <CODE>vlc-x.x.x</CODE> with all the binaries 'stripped' (that is, smallest size, unusable with a debugger)
+
! Description
 +
|-
 +
| <code>make package-win-common</code>
 +
| Creates a subdirectory named <code>vlc-x.x.x</code> with all the binaries. You can run VLC directly from this directory.
 +
|-
 +
| <code>make package-win-strip</code>
 +
| Same as above but will create 'stripped' binaries (that is, smallest size, unusable with a debugger).
 +
|-
 +
| <code>make package-win32-7zip</code>
 +
| Same as above but will package the directory in a 7z file.
 
|-
 
|-
| <CODE>make package-win32-zip</CODE>
+
| <code>make package-win32-zip</code>
 
| Same as above but will package the directory in a zip file.
 
| Same as above but will package the directory in a zip file.
 
|-
 
|-
| <CODE>make package-win32</CODE>
+
| <code>make package-win32</code>
 
| Same as above but will also create an auto-installer package. You must have NSIS installed in its default location for this to work.
 
| 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&mdash;you're ready to use VLC!'''''
+
'''''Well done—you're ready to use VLC!'''''  
 +
 
 +
== Extra information ==
 +
 
 +
=== Static compilation of plugins ===
 +
You might want to use the following script to enforce static compilation.
 +
Run as root, and use at your own risk.
 +
<syntaxhighlight lang="bash">
 +
#!/bin/sh
 +
 +
# This script enforces statically linking of libgcc, libstdc++-6, and libpthread,
 +
# without needing to rebuild gcc and mingw-w64 from scratch.
 +
# -static-libgcc -static-libstdc++ flags can not be used in a libtool build system,
 +
# as libtool removes flags that it doesn't understand.
 +
 +
move() {
 +
    [ -f $1 ] || return 1
 +
    mkdir -p old/
 +
    mv -v $* old/
 +
    return 0
 +
}
 +
 +
for x in i686 x86_64
 +
do
 +
    library_path_list=`$x-w64-mingw32-gcc -v /dev/null 2>&1 | grep ^LIBRARY_PATH|cut -d= -f2|sort|uniq`
 +
    IFS=':'
 +
    for i in $library_path_list
 +
    do
 +
        cd $i
 +
        move libstdc++-6.dll libstdc++.dll.a libgcc_s.a libgcc_s_sjlj-1.dll && ln -s libgcc_eh.a libgcc_s.a
 +
        move libpthread.dll.a libwinpthread.dll.a
 +
        move libwinpthread-1.dll
 +
        [ -d ../bin ] && cd ../bin && move libwinpthread-1.dll
 +
    done
 +
done
 +
 +
exit 0
 +
</syntaxhighlight>
 +
 
 +
=== Mingw32 ===
 +
Up to versions 2.0.x, VLC was compiled with the older mingw32 toolchain, which only supports 32-bits Windows. If you have problems with mingw-w64, you can try mingw32 instead:
 +
 
 +
* '''Debian/Ubuntu''': run <code>apt-get install gcc-mingw32 mingw32-binutils</code>. Note that at least version 3.17 of Mingw32 is required, which Debian does not provide. You may obtain mingw32-runtime-3.17 [http://people.videolan.org/~jb/debian/mingw32-runtime_3.17.0-0videolan_all.deb here].
 +
* '''Gentoo''' users can <code>emerge crossdev &amp;&amp; crossdev mingw32</code>
 +
* '''ArchLinux''' users can <code>pacman -S mingw32-gcc</code>
 +
* '''Fedora''' users should read [[Win32Compile Under Fedora]]
 +
* Other '''Linux''' systems may attempt http://www.mingw.org/wiki/LinuxCrossMinGW
  
 
[[Category:Building]]
 
[[Category:Building]]
 +
[[Category:Windows]]

Latest revision as of 16:18, 13 December 2022

WARNING: This page is deprecated, for updated instructions please follow: https://code.videolan.org/videolan/vlc/-/blob/master/doc/BUILD-win32.md

This page will help you to compile VLC media player for Windows.

Building Methods

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

Method Documentation Notes
MinGW on Linux Obtaining the toolchain Preferred method involving cross-compilation from Linux. On computers running Microsoft Windows, a virtual machine is necessary to run Linux.
MSYS+MinGW on Windows Compile with MSys Native compilation method. MSYS is a minimal build environment to compile Unix-style projects directly on Microsoft Windows. This is not officially supported by VideoLAN. Best of luck.
Cygwin on Windows Compile with Cygwin Cygwin method. Cygwin emulates a POSIX environment to compile on Microsoft Windows. This is error-prone and slow and therefore not recommended.

Obtaining the cross-compilation toolchain

All this howto is focused on Debian/Ubuntu. For other distribution, please find the related package names, but they should be very similar.

Ubuntu 14.04 is too old to compile VLC.

Host triplet

A number of commands below include the toolchain identifier, called the host triplet.

This value is essential: it instructs the build system to use the correct toolchain and compile the program for Windows. Without the value, the build system will perform a native compilation for Linux (or whatever your computer runs). With an incorrect value, the build will fail.

The exact value depends on your installation of the toolchain.

Notably on Debian/Ubuntu, these values must be used:

  • i686-w64-mingw32 for Windows 32-bits, using the Mingw-w64 toolchain
  • x86_64-w64-mingw32 for Windows 64-bits, using the Mingw-w64 toolchain

Please make sure that you replace the keywords HOST-TRIPLET with either i686-w64-mingw32 or x86_64-w64-mingw32 adapted to your target Windows version (32-bit or 64-bit, respectively)

Compiler and binary toolchain

Mingw-w64

To compile VLC for Windows (32-bits or 64-bits), the Mingw-w64 toolchain is required:

For the 32-bit version, run this:

# apt-get install gcc-mingw-w64-i686 g++-mingw-w64-i686 mingw-w64-tools

For the 64-bit version, this becomes:

# apt-get install gcc-mingw-w64-x86-64 g++-mingw-w64-x86-64 mingw-w64-tools

NB: you need mingw-w64 version 5.0.1 to compile it.

Development tools

You will also need:

  • lua (5.2)
  • all autotools: libtool, automake, autoconf, autopoint, make, gettext, pkg-config
  • qt4-dev-tools, qt5-default (or qt4-default if qt plugin build fails)
  • git, subversion cmake, cvs if you want to rebuild contribs
  • wine-dev for creating Win32 packages
  • zip [for creating .zip package], p7zip [for .7z package], nsis [for .exe auto-installer], bzip2 [for 'make prebuild]

Run:

# apt-get install lua5.2 libtool automake autoconf autopoint make gettext pkg-config
# apt-get install qt4-dev-tools qt5-default git subversion cmake cvs 
# apt-get install wine64-development-tools libwine-dev zip p7zip nsis bzip2
# apt-get install yasm ragel ant default-jdk protobuf-compiler dos2unix

Get the source code

$ git clone https://code.videolan.org/videolan/vlc.git vlc

See Git for more information.

Go into the VLC directory

$ cd vlc

Prepare 3rd party libraries

VLC depends on a sizable number of third party libraries. Before compiling VLC, you need to obtain compiled versions of those. There are two ways to achieve that:

  • The prebuilt approach is much faster and easier, but only works with a narrow set of VLC versions.
  • The manual build approach takes a lot of time and disk space, and somewhat error-prone.

Please note that the prebuilt library versions are intended for the latest current stable release of VLC. It is not compatible with old VLC versions, nor with newer or future versions.

At the time of writing (late 2016), the prebuilt libraries work with VLC 2.2.x only. To compile the VLC 3.0.x development branch, DO NOT USE the prebuilt libraries.

Prebuilt (fast)

 $ mkdir -p contrib/win32
 $ cd contrib/win32
 $ ../bootstrap --host=HOST-TRIPLET
 $ make prebuilt

Manually built (slow)

Or, if you want to compile the contribs yourself and are feeling adventurous and have lots of time to burn:

 # apt-get install subversion yasm cvs cmake ragel autopoint
 $ mkdir -p contrib/win32
 $ cd contrib/win32
 $ ../bootstrap --host=HOST-TRIPLET
 $ make fetch
 $ make

Linux 64-bit

If you are on Linux 64-bit, you SHOULD remove some files, or install the lib32 packages (ia32-libs, multilibs, etc...)

 $ rm -f ../i686-w64-mingw32/bin/moc ../i686-w64-mingw32/bin/uic ../i686-w64-mingw32/bin/rcc

Fix your contrib path

If your host triplet is not i686-w64-mingw32 (you are not compiling for Debian or Ubuntu), create a symlink to contribs:

$ ln -sf 'HOST-TRIPLET' ../i686-w64-mingw32

Notice that there is no ../ before the host triplet. This is intentional, and if done properly, you should see a functioning symbolic link created in the parent directory (try ls -l .. and you should see i686-w64-mingw32 -> x86_64-w64-mingw32/).

Go Back

Go back to the VLC source directory:

 $ cd -

Configuring the build

Bootstrap

First, prepare the tree:

 $ ./bootstrap

Configure

Then you can to configure the build with the ./configure script.

Create a subfolder:

 $ mkdir win32 && cd win32

Set your PKG_CONFIG_LIBDIR (Adapt the path to reflect your local setup)

 $ export PKG_CONFIG_LIBDIR=$HOME/vlc/contrib/HOST-TRIPLET/lib/pkgconfig
 $ export PKG_CONFIG_PATH_CUSTOM=$PKG_CONFIG_LIBDIR (for Archlinux only)

Execute the build configuration script:

$ ../extras/package/win32/configure.sh --host=HOST-TRIPLET --build=x86_64-pc-linux-gnu

N.B.: Use the host and build tuples respectively corresponding to your cross-compilation toolchain and build system respectively. The example above assumes you are compiling for Windows OS and Intel 686 architecture, and the build system is GNU/Linux OS and x86 64-bits architecture. See above for list of common values.

Also, if you have a problem here (such as an error about Library dvdread), see the Talk page.

Alternatively, you can run configure manually:

$ ../configure --host=HOST-TRIPLET --build=x86_64-pc-linux-gnu

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

Building VLC

Once configured, to build VLC, just run:

 $ make

Packaging VLC

Once the compilation is done, you can build self-contained VLC packages with the following make rules:

Command Description
make package-win-common Creates a subdirectory named vlc-x.x.x with all the binaries. You can run VLC directly from this directory.
make package-win-strip Same as above but will create 'stripped' binaries (that is, smallest size, unusable with a debugger).
make package-win32-7zip Same as above but will package the directory in a 7z file.
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!

Extra information

Static compilation of plugins

You might want to use the following script to enforce static compilation. Run as root, and use at your own risk.

 #!/bin/sh
 
 # This script enforces statically linking of libgcc, libstdc++-6, and libpthread,
 # without needing to rebuild gcc and mingw-w64 from scratch.
 # -static-libgcc -static-libstdc++ flags can not be used in a libtool build system,
 # as libtool removes flags that it doesn't understand.
 
 move() {
     [ -f $1 ] || return 1
     mkdir -p old/
     mv -v $* old/
     return 0
 }
 
 for x in i686 x86_64
 do
     library_path_list=`$x-w64-mingw32-gcc -v /dev/null 2>&1 | grep ^LIBRARY_PATH|cut -d= -f2|sort|uniq`
     IFS=':'
     for i in $library_path_list
     do
         cd $i
         move libstdc++-6.dll libstdc++.dll.a libgcc_s.a libgcc_s_sjlj-1.dll && ln -s libgcc_eh.a libgcc_s.a
         move libpthread.dll.a libwinpthread.dll.a
         move libwinpthread-1.dll
         [ -d ../bin ] && cd ../bin && move libwinpthread-1.dll
     done
 done
 
 exit 0

Mingw32

Up to versions 2.0.x, VLC was compiled with the older mingw32 toolchain, which only supports 32-bits Windows. If you have problems with mingw-w64, you can try mingw32 instead:

  • Debian/Ubuntu: run apt-get install gcc-mingw32 mingw32-binutils. Note that at least version 3.17 of Mingw32 is required, which Debian does not provide. You may obtain mingw32-runtime-3.17 here.
  • Gentoo users can emerge crossdev && crossdev mingw32
  • ArchLinux users can pacman -S mingw32-gcc
  • Fedora users should read Win32Compile Under Fedora
  • Other Linux systems may attempt http://www.mingw.org/wiki/LinuxCrossMinGW