Difference between revisions of "Win32CompileMSYS"

From VideoLAN Wiki
Jump to navigation Jump to search
 
(108 intermediate revisions by 5 users not shown)
Line 1: Line 1:
 
= Introduction  =
 
= Introduction  =
== About ==
+
[http://sourceforge.net/projects/msys2/ MSys2] is a helper environment for MinGW, the compiler chain for Windows based on GCC.
  
MSys is a helper environment for MinGW, the compiler chain for Windows based on GCC. It can build VLC natively on Windows. Note that you should also [[Win32Compile|cross compile]] VLC from Linux, because it is faster, and feels easier.
+
It can build VLC natively on Microsoft Windows. However, VideoLAN developers '''strongly recommend''' [[Win32Compile|cross-compiling VLC from Linux]], which is faster and easier. If you decide to stick to the MSYS method, you are on your own. Should you encounter any problem and ask for help, expect to be told to cross-compile.
  
VLC is a complex program with many dependencies, so minimal command-line experience is required. Also, don't be in a hurry (4 hours is a minimum for the whole process) and don't despair if it doesn't work first time.
+
Either way, VLC is a complex program with many dependencies, most of which are obtained/built through the command line interface. Therefore, experience with the POSIX command line (i.e. the ''Unix shell'') is '''required'''.  
 +
Time, patience and persistence are indispensable. The entire process outlined below should take at the very least 4 hours. Experience show that mistakes are common, especially with beginners, so you might need to make multiple attempts.
  
== Acknowledgements ==
+
= Install Windows tools =
 +
== Text editor  ==
 +
To edit unix-style text documents you need a suitable editor: Notepad is not enough.
  
This howto was re-created by [[User:J-b|Jean-Baptiste Kempf]] and updated in June 2009, September 2009, December 2009 and March 2010.  
+
* Use [http://sourceforge.net/projects/notepad2/ notepad2]. You can set File - Line endings - Default to "Unix (LF)", but it always saves opened files in the ending style they have.
  
It was updated in June 2010 by Vicne with the help of J-b, gnosygnu and MichaelMc
+
* Or use [http://notepad-plus-plus.org/ notepad++].
  
It was updated in July 2012 by gnosygnu. Note that there are several new notes in [[Win32CompileMSYSTroubleShooting]]. These reflect problems that were encountered on gnosygnu's setup (Windows XP SP3). Refer to this [http://forum.videolan.org/viewtopic.php?f=32&t=102843&sid=f58967215a83981dda030ff6efa3d493 forum thread] for more information.
+
== Unzip Utility (7-zip) ==
 +
Files to downloaded will have to be uncompressed. Some of them use Unix originated formats (.tar.gz, .tar.bz2, .tar.lzma), you will then need a versatile unzipping utility.  
  
= Windows tools needed  =
+
A recent version of [http://www.7-zip.org/ 7-zip] is therefore strongly advised.
== Text editor  ==
 
  
To edit unix-style text documents you need a suitable editor.  
+
= Install MSys2 and GCC =
 +
Install MSys2 from http://msys2.github.io/
  
You can look at [http://sourceforge.net/projects/notepad2/ notepad2]. You can set File - Line endings - Default to "Unix (LF)", but it always saves opened files in the ending style they have.
+
We recommend to use the 32bits version.
  
Or you can look at [http://notepad-plus-plus.org/ notepad++].
+
Let the default, and run the command line.
  
== Unzip Utility (7-zip) ==
+
== Tools ==
 +
Install the autotools suite:
 +
  pacman -S git subversion cvs automake autoconf libtool m4 make gettext pkg-config mingw-w64-i686-lua findutils  mingw-w64-i686-headers yasm patch
  
Many files to downloaded will have to be uncompressed. As most of them use Linux-originated formats (.tar.gz, .tar.bz2, .tar.lzma), you will need a versatile unzipping utility. A recent version of [http://www.7-zip.org/ 7-zip] is therefore strongly advised.  
+
=== gcc ===
 +
Download gcc from:
 +
[http://sourceforge.net/projects/mingw-w64/files/Toolchains%20targetting%20Win32/Personal%20Builds/mingw-builds/4.9.2/threads-win32/sjlj/i686-4.9.2-release-win32-sjlj-rt_v3-rev0.7z/download mingw-w64].
  
Please note that most archives contain directory structures. Unless otherwise stated, you have to merge the contents with the existing dirs
+
Unzip it to C:\MSys2\
  
= GNU Windows Environment  =
+
=== Restart ===
Before installing, ensure your Windows user name does not contain spaces (VLC will not build in a folder with spaces in it). If it does, please create another user on your system.  
+
'''Exit MSys2, run ''autorebase.bat'' and re-run MSys2 from ''mingw32_shell.bat'''''
  
In the following text, we'll refer to this user name as "<username>". Replace it appropriately where needed of course.
+
== Check GCC ==
 +
Run
 +
gcc -v
  
== MinGW ==
+
And check that it says
=== TDM/MinGW Setup  ===
+
  Thread model: win32
 +
gcc version 4.9.2 (i686-win32-sjlj-rev0, Built by MinGW-W64 project)
  
Use the installer found at http://sourceforge.net/projects/tdm-gcc/files/TDM-GCC%20Installer/tdm-gcc-4.7.1-2.exe/download
+
= Get VLC sources  =
  
Go through the wizard:
+
== Git ==
* Select "Create"
+
<big>'''YOU MUST''' keep the native line-endings of the repo.</big>
* Select 32bits
+
git config core.autocrlf=false
* Install to C:\MinGW
 
* Keep default settings
 
 
 
== MSys  ==
 
Use the MSys package found at
 
 
 
Unzip it to C:\MinGW
 
  
= VLC sources  =
 
== Git ==
 
 
Clone the git repo
 
Clone the git repo
 
  git clone git://git.videolan.org/vlc.git
 
  git clone git://git.videolan.org/vlc.git
  
= Get Precompiled contribs  =
+
'''Nota Bene:''' ensure your Windows user name does not contain spaces so that the cloning folder of VLC will not not have spaces in it.
 +
 
 +
= Get precompiled 3rd party libraries =
 
  cd vlc/contrib
 
  cd vlc/contrib
 
  mkdir win32 && cd win32
 
  mkdir win32 && cd win32
  ../bootstrap --build=i586-mingw32msvc
+
  ../bootstrap --build=i686-w64-mingw32
 
  make prebuilt
 
  make prebuilt
  
'''Note''': it will say tar complains, just ignore them and watch tar die.
+
'''Note:''' check that all is well with moc -v
I had to manually execute the rest of the prebuilt target, which consists of
 
 
 
mv i586-mingw32msvc ..
 
cd ../i586-mingw32msvc
 
change_prefix.sh
 
 
 
I also found that change_prefix.sh, which rewrites .pc files to deal with their chosen location, used the -i option which is not supported by MSYS-shipped sed. I rewrote the sed script to write changes $file.new then mv $file.new $file.
 
 
 
= Last change&nbsp;: whoami and hostname  =
 
 
 
Whoami is not available on Windows, and hostname doesn't support the -f option used by the build process. These utilities are used to show the name and computer of the person who compiled VLC in the 'About' box.
 
 
 
:''Note for the brave&nbsp;: the steps below are file changes so that compile works, but an alternative is to download and install GNU whoami and hostname functionality. This can be achieved by doing the following steps:
 
# ''download coreutils from http://sourceforge.net/projects/mingw/files/MSYS/BaseSystem/coreutils, selecting any version (latter is normally better) then the file named like coreutils-5.97-2-msys-1.0.11-ext.tar.lzma (note '-ext' in file name) and extracting who.exe, whoami.exe, hostname.exe to C:/MSys/1.0/bin''
 
# ''download libintl dll from http://sourceforge.net/projects/mingw/files/MSYS/BaseSystem/libiconv, selecting any version (latter is normally better) then the file named like libiconv-1.13.1-2-msys-1.0.13-dll-2.tar.lzma (note '-dll' in file name) and extracting dll in C:/MSys/1.0/bin''
 
# ''download libiconv dll from http://sourceforge.net/projects/mingw/files/MSYS/BaseSystem/gettext, selecting any version (latter is normally better) then the file named like libintl-0.17-2-msys-dll-8.tar.lzma (note '-dll' in file name) and extracting dll in C:/MSys/1.0/bin''
 
 
 
== Whoami  ==
 
 
 
Create a new file containing the single line:
 
 
 
echo '&lt;username&gt;'
 
 
 
and save it as C:\MSys\1.0\bin\whoami (without any extension)
 
 
 
== Hostname  ==
 
 
 
Modify configure.ac so that it doesn't call 'hostname -f' as follows:
 
 
 
*open C:\MSys\1.0\home\&lt;username&gt;\vlc\configure.ac
 
*goto search button:
 
*change it as follows:
 
 
 
old: AC_DEFINE_UNQUOTED(VLC_COMPILE_HOST, "`hostname -f 2&gt; /dev/null || hostname`", [host which ran configure])
 
new: AC_DEFINE_UNQUOTED(VLC_COMPILE_HOST, "`hostname`", [host which ran configure])
 
  
 
= Build VLC  =
 
= Build VLC  =
 
The build is made exclusively from the command line, so if you closed the prompt at the LUA step, re-execute C:\MSys\1.0\msys.bat, then type the commands as mentioned
 
  
 
== Bootstrap  ==
 
== Bootstrap  ==
 +
In VLC root folder, do:
 +
./bootstrap
  
cd vlc
 
cp -v /usr/share/aclocal/* m4/
 
bootstrap
 
 
== Configure  ==
 
== Configure  ==
 +
mkdir win32
 +
cd win32
 +
sh ../extras/package/win32/configure.sh --host=i686-w64-mingw32 --disable-nls
  
sh extras/package/win32/configure.sh --host=i586-pc-mingw32msvc --disable-nls
+
'''Note:''' If you want any custom options, like "--disable-lua" or anything of that nature, you can append them.
 
 
If you want any custom options, like "--disable-lua" or anything of that nature, you can append them.
 
  
 
== Make (compile) ==
 
== Make (compile) ==
 +
make -j4
  
Note&nbsp;: If your &lt;username&gt; starts with the "u" or "x" character, change C:\MSys\1.0\home\&lt;username&gt;\config.h and double all backslashes in VLC_COMPILED_BY constant.  
+
'''Note:''' If your &lt;username&gt; starts with the "u" or "x" character, change C:\MSys\1.0\home\&lt;username&gt;\config.h and double all backslashes in VLC_COMPILED_BY constant.
 
 
Type the following command&nbsp;:
 
 
 
PATH=/usr/win32/bin:$PATH make
 
 
 
If this step fails, try the following
 
* Go back to "Precompiled contribs" section, and obtain the latest compiled contrib (under "Note for the brave")
 
* In the configure script section (configure-msys.sh), open that file and add --disable-upnp
 
 
 
== Create self-contained packages  ==
 
  
 +
= Create packages  =
 +
== Run VLC ==
 
Once the compilation is done, build self-contained VLC packages with one of the following "make" commands:  
 
Once the compilation is done, build self-contained VLC packages with one of the following "make" commands:  
  
  make package-win32-base
+
  make package-win-common
  
(This will create a subdirectory named vlc-x.x.x with all the binaries "stripped" without any debugging symbols).  
+
This will create a subdirectory named vlc-x.x.x with all the binaries with debugging symbols. You can run ./vlc.exe from there.
  
 +
== Create proper packages ==
 
  make package-win32-zip
 
  make package-win32-zip
  
 
(Same as above but will package the directory in a zip file).  
 
(Same as above but will package the directory in a zip file).  
  
  make package-win32
+
  make package-win32-exe
  
 
(Same as above but will also create an auto-installer package. You will need to have NSIS installed in its default location for this to work).
 
(Same as above but will also create an auto-installer package. You will need to have NSIS installed in its default location for this to work).
  
make package-win32-base-debug
+
= Troubleshooting =
  
(This will create a subdirectory named vlc-x.x.x with all the binaries containing debug info usable by gdb).
+
See [[Win32CompileMSYSTroubleShooting]].
 +
 
 +
== Acknowledgements ==
 +
 
 +
This howto was re-created by [[User:J-b|Jean-Baptiste Kempf]] and updated in June 2009, September 2009, December 2009 and March 2010.  
  
Note that with the 1.2 branch these names have changed slightly.  Run '
+
It was updated in June 2010 by Vicne with the help of J-b, gnosygnu and MichaelMc
grep ':' Makefile | grep package-win32
 
to see what they are now.
 
  
= Troubleshooting =
+
It was updated in July 2012 by gnosygnu. Note that there are several new notes in [[Win32CompileMSYSTroubleShooting]]. These reflect problems that were encountered on gnosygnu's setup (Windows XP SP3). Refer to this [http://forum.videolan.org/viewtopic.php?f=32&t=102843&sid=f58967215a83981dda030ff6efa3d493 forum thread] for more information.
  
See [[Win32CompileMSYSTroubleShooting]].
+
This howto was re-re-created by [[User:J-b|Jean-Baptiste Kempf]] in September 2012 and updated until 2015, with MSys2
  
 
= See also =
 
= See also =
 
*[[Win32CompileMSYSOld]] - deprecated documentation
 
*[[Win32CompileMSYSOld]] - deprecated documentation
 +
 +
[[Category:Building]]
 +
[[Category:Windows]]

Latest revision as of 20:23, 15 February 2019

Introduction

MSys2 is a helper environment for MinGW, the compiler chain for Windows based on GCC.

It can build VLC natively on Microsoft Windows. However, VideoLAN developers strongly recommend cross-compiling VLC from Linux, which is faster and easier. If you decide to stick to the MSYS method, you are on your own. Should you encounter any problem and ask for help, expect to be told to cross-compile.

Either way, VLC is a complex program with many dependencies, most of which are obtained/built through the command line interface. Therefore, experience with the POSIX command line (i.e. the Unix shell) is required. Time, patience and persistence are indispensable. The entire process outlined below should take at the very least 4 hours. Experience show that mistakes are common, especially with beginners, so you might need to make multiple attempts.

Install Windows tools

Text editor

To edit unix-style text documents you need a suitable editor: Notepad is not enough.

  • Use notepad2. You can set File - Line endings - Default to "Unix (LF)", but it always saves opened files in the ending style they have.

Unzip Utility (7-zip)

Files to downloaded will have to be uncompressed. Some of them use Unix originated formats (.tar.gz, .tar.bz2, .tar.lzma), you will then need a versatile unzipping utility.

A recent version of 7-zip is therefore strongly advised.

Install MSys2 and GCC

Install MSys2 from http://msys2.github.io/

We recommend to use the 32bits version.

Let the default, and run the command line.

Tools

Install the autotools suite:

 pacman -S git subversion cvs automake autoconf libtool m4 make gettext pkg-config mingw-w64-i686-lua findutils  mingw-w64-i686-headers yasm patch

gcc

Download gcc from: mingw-w64.

Unzip it to C:\MSys2\

Restart

Exit MSys2, run autorebase.bat and re-run MSys2 from mingw32_shell.bat

Check GCC

Run

gcc -v

And check that it says

Thread model: win32
gcc version 4.9.2 (i686-win32-sjlj-rev0, Built by MinGW-W64 project)

Get VLC sources

Git

YOU MUST keep the native line-endings of the repo.

git config core.autocrlf=false

Clone the git repo

git clone git://git.videolan.org/vlc.git

Nota Bene: ensure your Windows user name does not contain spaces so that the cloning folder of VLC will not not have spaces in it.

Get precompiled 3rd party libraries

cd vlc/contrib
mkdir win32 && cd win32
../bootstrap --build=i686-w64-mingw32
make prebuilt

Note: check that all is well with moc -v

Build VLC

Bootstrap

In VLC root folder, do:

./bootstrap

Configure

mkdir win32
cd win32
sh ../extras/package/win32/configure.sh --host=i686-w64-mingw32 --disable-nls

Note: If you want any custom options, like "--disable-lua" or anything of that nature, you can append them.

Make (compile)

make -j4

Note: If your <username> starts with the "u" or "x" character, change C:\MSys\1.0\home\<username>\config.h and double all backslashes in VLC_COMPILED_BY constant.

Create packages

Run VLC

Once the compilation is done, build self-contained VLC packages with one of the following "make" commands:

make package-win-common

This will create a subdirectory named vlc-x.x.x with all the binaries with debugging symbols. You can run ./vlc.exe from there.

Create proper packages

make package-win32-zip

(Same as above but will package the directory in a zip file).

make package-win32-exe

(Same as above but will also create an auto-installer package. You will need to have NSIS installed in its default location for this to work).

Troubleshooting

See Win32CompileMSYSTroubleShooting.

Acknowledgements

This howto was re-created by Jean-Baptiste Kempf and updated in June 2009, September 2009, December 2009 and March 2010.

It was updated in June 2010 by Vicne with the help of J-b, gnosygnu and MichaelMc

It was updated in July 2012 by gnosygnu. Note that there are several new notes in Win32CompileMSYSTroubleShooting. These reflect problems that were encountered on gnosygnu's setup (Windows XP SP3). Refer to this forum thread for more information.

This howto was re-re-created by Jean-Baptiste Kempf in September 2012 and updated until 2015, with MSys2

See also