Difference between revisions of "Win32Compile Under Fedora"

From VideoLAN Wiki
Jump to navigation Jump to search
(preliminary first edit)
Line 1: Line 1:
How to compile {{VLC}} for [[Windows]].
+
THIS PAGE IS UNDER CONSTRUCTION. CHECK BACK LATER THIS WEEK.
  
== Building Methods<br> ==
+
How to compile {{VLC}} for [[Windows]] under Fedora.
  
If you want to build VLC from source under Fedora, you have several choices:
+
== Building Methods ==
 +
 
 +
From a Fedora 64-bit install, you have two basic approaches if you want to build VLC from source.
  
 
{| class="wikitable"
 
{| class="wikitable"
Line 12: Line 14:
 
|-
 
|-
 
| '''Cross-compile with Mingw''' in a virtual machine.  
 
| '''Cross-compile with Mingw''' in a virtual machine.  
| '''Preferred''' method.
+
| '''Preferred''' method that works "out of the box".
 
|-
 
|-
 
| '''Cross-compile with Mingw''' under Fedora.  
 
| '''Cross-compile with Mingw''' under Fedora.  
 +
| Produces some anomalies and requires some workarounds.
 
|}
 
|}
  
 
Yum is the basic installation tool for Fedora. Install packages (as root):
 
Yum is the basic installation tool for Fedora. Install packages (as root):
 
<pre>
 
<pre>
sudo yum install ''package-name1 package-name2 ...''
+
$ sudo yum install ''package-name1 package-name2 ...''
 
</pre>
 
</pre>
  
Line 25: Line 28:
 
Virtual Box is known to work for this approach.  
 
Virtual Box is known to work for this approach.  
 
<pre>
 
<pre>
sudo yum install VirtualBox-OSE
+
$ sudo yum install VirtualBox-OSE
 
</pre>
 
</pre>
  
Line 31: Line 34:
  
 
<pre>
 
<pre>
wget http://www.ubuntu.com/start-download?distro=desktop&bits=32&release=latest
+
$ wget http://www.ubuntu.com/start-download?distro=desktop&bits=32&release=latest
 
</pre>
 
</pre>
  
Line 58: Line 61:
 
* Click on Start.
 
* Click on Start.
  
Now Ubuntu should start. From here you can follow the instructions on the main Win32Compile page.
+
Now Ubuntu should start. From here you can follow the instructions on the main [[Win32Compile]] page.
  
 
   
 
   
Line 67: Line 70:
 
First, change to a directory you will use for building. You must have write access to this directory. Then use git to get the source:
 
First, change to a directory you will use for building. You must have write access to this directory. Then use git to get the source:
 
<pre>
 
<pre>
git clone git://git.videolan.org/vlc.git
+
$ git clone git://git.videolan.org/vlc.git
 
</pre>
 
</pre>
  
 
This will give you the VLC trunk. Alternative branches (technically forks) are listed at http://git.videolan.org. Scroll down to the vlc.git line and click on the "forks" link at the extreme right. This will give you a list of alternatives, which are in the vlc directory. So, for example, to choose the 2.0 fork, the command is:
 
This will give you the VLC trunk. Alternative branches (technically forks) are listed at http://git.videolan.org. Scroll down to the vlc.git line and click on the "forks" link at the extreme right. This will give you a list of alternatives, which are in the vlc directory. So, for example, to choose the 2.0 fork, the command is:
 
<pre>
 
<pre>
git clone git://git.videolan.org/vlc/vlc-2.0.git
+
$ git clone git://git.videolan.org/vlc/vlc-2.0.git
 
</pre>  
 
</pre>  
  
 
Next, change into the newly installed vlc-x.x directory. We will refer to this as the $VLCROOT directory:
 
Next, change into the newly installed vlc-x.x directory. We will refer to this as the $VLCROOT directory:
 
<pre>
 
<pre>
export VLCROOT=`pwd`
+
$ cd vlc-*
 +
$ export VLCROOT=`pwd`
 
</pre>
 
</pre>
  
Line 84: Line 88:
 
The mingw32 cross-compile tools are available in the default repository.  
 
The mingw32 cross-compile tools are available in the default repository.  
 
<pre>
 
<pre>
sudo yum install \
+
$ sudo yum install \
 
mingw32-gcc-c++ \
 
mingw32-gcc-c++ \
 
mingw32-gcc \
 
mingw32-gcc \
Line 96: Line 100:
 
</pre>
 
</pre>
  
== Installing 32-bit Lua ==
+
== Prepare [[Contrib Status|3rd party libraries]]  ==
By default, you will already have 64-bit Lua installed, because the yum/RPM packaging system depends on it. As a result, you will not be able to remove the 64-bit version. Furthermore, you may install the 32-bit binary libraries, but the 32-bit binary executables (lua and luac) will NOT install over the 64-bit ones. Here is how to work around that.
 
  
 +
Before compiling VLC, you need lots of other libraries. Here is how to get them:
 
<pre>
 
<pre>
sudo yum install compat-readline5.i686
+
$ mkdir -p contrib/win32
yumdownloader lua.i686
+
$ cd contrib/win32
sudo yum localinstall ./lua*.rpm
+
$ ../bootstrap --host=i586-mingw32msvc
 +
$ make prebuilt
 +
$ cd ..
 +
$ ln -s i586-mingw32msvc i686-pc-mingw32
 
</pre>
 
</pre>
  
This installs the 32-bit libraries but not the executables. You have to manually extract and install the 32-bit versions
+
Note that <code>i686-pc-mingw32</code> is the current name of the "host" system for cross-compiling. You can verify that by:
 
<pre>
 
<pre>
sudo yum install cpio
+
$ rpm -ql mingw32-filesystem|grep -m1 lib|cut -d/ -f3
rpm2cpio lua*.rpm | cpio -idmv
 
 
</pre>
 
</pre>
Now you will have the files from the RPM package as a tree in your local directory. They have the same names and (relative) locations as the 64-bit versions, which is why yum refused to install them in the first place. So manually install them with the names lua32 and luac32:
+
 
 +
== Installing 32-bit Lua ==
 +
By default, you will already have 64-bit Lua installed, because the Yum/RPM packaging system depends on it. As a result, you will not be able to remove the 64-bit version. Furthermore, you may install the 32-bit binary libraries, but the 32-bit binary executables (<code>lua</code> and <code>luac</code>) will NOT install over the 64-bit ones. Here is how to work around that.
  
 
<pre>
 
<pre>
sudo mv usr/bin/lua /usr/bin/lua32
+
$ sudo yum install compat-readline5.i686
sudo mv usr/bin/luac /usr/bin/luac32
+
$ yumdownloader lua.i686
rm -rf usr
+
$ sudo yum localinstall ./lua*.rpm
rm -f lua*.rpm
 
 
</pre>
 
</pre>
  
Tell the build system where to find the 32-bit versions:
+
This installs the 32-bit libraries but not the executables. You have to manually extract and install the 32-bit versions.
 
<pre>
 
<pre>
export LUA=/usr/bin/lua32
+
$ sudo yum install cpio
export LUAC=/usr/bin/luac32
+
$ rpm2cpio lua*.rpm | cpio -idmv
 +
</pre>
 +
Now you will have the files from the RPM package as a tree in your local directory. They have the same names and (relative) locations as the 64-bit versions, which is why Yum refused to install them in the first place. So manually install them with the names <code>lua32</code> and <code>luac32</code> and get rid of your detritus.
 +
<pre>
 +
$ sudo mv usr/bin/lua /usr/bin/lua32
 +
$ sudo mv usr/bin/luac /usr/bin/luac32
 +
$ rm -rf usr
 +
$ rm -f lua*.rpm
 +
</pre>
 +
Tell the build system where to find the 32-bit versions.
 +
<pre>
 +
$ export LUA=/usr/bin/lua32
 +
$ export LUAC=/usr/bin/luac32
 
</pre>
 
</pre>
  
 
== Installing Qt and Correcting Version Mismatch ==
 
== Installing Qt and Correcting Version Mismatch ==
  
Install the qt-devel package, which gives you moc, uic and rcc for both Qt3 and Qt4. The executables for Qt4 are named moc-qt4, uic-qt4 and rcc.
+
Install the <code>qt-devel</code> package, which gives you <code>moc</code>, <code>uic</code> and <code>rcc</code> for both Qt3 and Qt4. The executables for Qt4 are named <code>moc-qt4</code>, <code>uic-qt4</code> and <code>rcc</code>, so these need fixing as well.
 +
<pre>
 +
$ sudo yum install qt-devel
 +
$ sudo ln -s /usr/bin/moc-qt4 /usr/local/bin/moc
 +
$ sudo ln -s /usr/bin/uic-qt4 /usr/local/bin/uic
 +
</pre>
 +
 
 +
Your version of <code>moc</code> needs to match the version used in the contribs.
 
<pre>
 
<pre>
sudo yum install qt-devel
+
$ moc -v
 +
Qt Meta Object Compiler version 63 (Qt 4.8.0)
 +
$ grep "define Q_MOC" contrib/win32/i586-mingw32msvc/include/qt4/src/corelib/kernel/qobjectdefs.h
 +
#define Q_MOC_OUTPUT_REVISION 62
 
</pre>
 
</pre>
Your version of moc needs to match the version used in the VLC sources.
+
 
 +
In this case, the installed <code>moc</code> has a version of 63 (from Qt 4.8), but the contribs were built with version 62 (from Qt 4.7). To fix this:
 
<pre>
 
<pre>
moc -v
+
$ cd contrib/win32
 +
$ wget http://johnfreed.com/vlc/contrib/moc-`moc -v 2>&1|cut -d' ' -f6`.tar.bz2
  
</pre>
 
  
Note: pre-built Windows Qt is 4.6.0 but the yum installed version for Linux is actually 4.6.3...
 
''If it is problematic'' try to downgrade the qt installed versions:
 
  
 
=== tools ===
 
=== tools ===
Line 150: Line 178:
 
* zip [for creating .zip package], p7zip [for .7z package], nsis [for .exe auto-installer].
 
* zip [for creating .zip package], p7zip [for .7z package], nsis [for .exe auto-installer].
  
== Get the source code ==
 
$ git clone git://git.videolan.org/vlc.git
 
 
== Prepare [[Contrib Status|3rd party libraries]]  ==
 
 
Before compiling VLC, you need lots of other libraries. Here is how to get them:
 
 
  $ mkdir -p contrib/win32
 
  $ cd contrib/win32
 
  $ ../bootstrap --host=i586-mingw32msvc
 
  $ make prebuilt
 
 
or, if you want to compile the contribs yourself and are feeling adventurous and have lots of time to burn,
 
  
  $ mkdir -p contrib/win32
 
  $ cd contrib/win32
 
  $ ../bootstrap --host=i586-mingw32msvc
 
  $ make fetch
 
  $ make
 
  
 
=== Linux 64-bit ===
 
=== Linux 64-bit ===
Line 181: Line 191:
  
 
If your Mingw prefix is not ''i586-mingw32msvc'' (you are NOT on Debian or Ubuntu), create a symlink to contribs:
 
If your Mingw prefix is not ''i586-mingw32msvc'' (you are NOT on Debian or Ubuntu), create a symlink to contribs:
  $ ln -sf ../i586-mingw32msvc ../i486-mingw32
 
  
 
=== Go Back  ===
 
=== Go Back  ===

Revision as of 23:07, 6 February 2012

THIS PAGE IS UNDER CONSTRUCTION. CHECK BACK LATER THIS WEEK.

How to compile VLC media player for Windows under Fedora.

Building Methods

From a Fedora 64-bit install, you have two basic approaches if you want to build VLC from source.

Method Documentation Notes
Cross-compile with Mingw in a virtual machine. Preferred method that works "out of the box".
Cross-compile with Mingw under Fedora. Produces some anomalies and requires some workarounds.

Yum is the basic installation tool for Fedora. Install packages (as root):

$ sudo yum install ''package-name1 package-name2 ...''

Using a virtual machine

Virtual Box is known to work for this approach.

$ sudo yum install VirtualBox-OSE

The basic Win32Compile is optimized for Ubuntu. It is simpler if you install the 32-bit version:

$ wget http://www.ubuntu.com/start-download?distro=desktop&bits=32&release=latest

Start the VirtualBox Manager GUI.

  • Click on Machine / New... The "New Virtual Machine Wizard" will open.
  • Click Next. Enter Ubuntu32 in the Name box.
  • Set Base Memory Size to 1024MB. (Recommended.)
  • Leave Start-up Disk box checked. Leave Create new hard disk radio button active.
  • Choose VDI file type.
  • Choose Dynamically allocated
  • Choose Location Ubuntu32 and Size 8.00 GB
  • Click "Create". This will exit the Wizard.
  • Click "Create" again. This will create the virtual machine.
  • Click Settings / Storage. The SATA Controller should show that Ubuntu32.vdi (your 8GB disk) is attached. The IDE Controller should show an empty attachment. Click on the Empty line. The Attributes label in the last column should read "CD/DVD Drive:" with a dropdown reading "IDE Secondary". To the right of that is a CD symbol. Click on that.
  • Click on "Choose a virtual CD/DVD disk file..."
  • Navigate to the Ubuntu server you just downloaded. Click Open. Your CD should now be attached to the IDE Controller. Click OK.
  • Click on Start.

At this point, the virtual machine should boot and take you through the Ubuntu installation process. When it is complete, it will ask you to remove the CD and reboot.

  • Click on Machine / Close ...
  • Choose Power off the machine and click OK.
  • Click on Settings / Storage
  • Click on the Ubuntu CD attached to the IDE Controller
  • Click on the CD symbol at the extreme right of the Attributes section.
  • Choose Remove disk from virtual drive. Click OK
  • Click on Start.

Now Ubuntu should start. From here you can follow the instructions on the main Win32Compile page.


Using Fedora

It is possible to compile the Windows 32-bit version under 64-bit Fedora. There are a few complications, as noted below.

Get the source code

First, change to a directory you will use for building. You must have write access to this directory. Then use git to get the source:

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

This will give you the VLC trunk. Alternative branches (technically forks) are listed at http://git.videolan.org. Scroll down to the vlc.git line and click on the "forks" link at the extreme right. This will give you a list of alternatives, which are in the vlc directory. So, for example, to choose the 2.0 fork, the command is:

$ git clone git://git.videolan.org/vlc/vlc-2.0.git

Next, change into the newly installed vlc-x.x directory. We will refer to this as the $VLCROOT directory:

$ cd vlc-*
$ export VLCROOT=`pwd`

Obtaining the toolchain

The mingw32 cross-compile tools are available in the default repository.

$ sudo yum install \
mingw32-gcc-c++ \
mingw32-gcc \
mingw32-pthreads \
mingw32-w32api \
mingw32-binutils \
mingw32-runtime \
mingw32-filesystem \
mingw32-cpp \
mingw32-dlfcn-static

Prepare 3rd party libraries

Before compiling VLC, you need lots of other libraries. Here is how to get them:

$ mkdir -p contrib/win32
$ cd contrib/win32
$ ../bootstrap --host=i586-mingw32msvc
$ make prebuilt
$ cd ..  
$ ln -s i586-mingw32msvc i686-pc-mingw32

Note that i686-pc-mingw32 is the current name of the "host" system for cross-compiling. You can verify that by:

$ rpm -ql mingw32-filesystem|grep -m1 lib|cut -d/ -f3

Installing 32-bit Lua

By default, you will already have 64-bit Lua installed, because the Yum/RPM packaging system depends on it. As a result, you will not be able to remove the 64-bit version. Furthermore, you may install the 32-bit binary libraries, but the 32-bit binary executables (lua and luac) will NOT install over the 64-bit ones. Here is how to work around that.

$ sudo yum install compat-readline5.i686 
$ yumdownloader lua.i686
$ sudo yum localinstall ./lua*.rpm

This installs the 32-bit libraries but not the executables. You have to manually extract and install the 32-bit versions.

$ sudo yum install cpio
$ rpm2cpio lua*.rpm | cpio -idmv

Now you will have the files from the RPM package as a tree in your local directory. They have the same names and (relative) locations as the 64-bit versions, which is why Yum refused to install them in the first place. So manually install them with the names lua32 and luac32 and get rid of your detritus.

$ sudo mv usr/bin/lua /usr/bin/lua32
$ sudo mv usr/bin/luac /usr/bin/luac32
$ rm -rf usr
$ rm -f lua*.rpm

Tell the build system where to find the 32-bit versions.

$ export LUA=/usr/bin/lua32
$ export LUAC=/usr/bin/luac32

Installing Qt and Correcting Version Mismatch

Install the qt-devel package, which gives you moc, uic and rcc for both Qt3 and Qt4. The executables for Qt4 are named moc-qt4, uic-qt4 and rcc, so these need fixing as well.

$ sudo yum install qt-devel
$ sudo ln -s /usr/bin/moc-qt4 /usr/local/bin/moc
$ sudo ln -s /usr/bin/uic-qt4 /usr/local/bin/uic

Your version of moc needs to match the version used in the contribs.

$ moc -v
Qt Meta Object Compiler version 63 (Qt 4.8.0)
$ grep "define Q_MOC" contrib/win32/i586-mingw32msvc/include/qt4/src/corelib/kernel/qobjectdefs.h
#define Q_MOC_OUTPUT_REVISION 62

In this case, the installed moc has a version of 63 (from Qt 4.8), but the contribs were built with version 62 (from Qt 4.7). To fix this:

$ cd contrib/win32
$ wget http://johnfreed.com/vlc/contrib/moc-`moc -v 2>&1|cut -d' ' -f6`.tar.bz2



=== tools ===
You will also need:
* lua5.1
* all autotools: libtool, automake, autoconf, autopoint, make, gettext
* pkg-config
* git
* subversion
* cmake, cvs if you want to rebuild contribs
* zip [for creating .zip package], p7zip [for .7z package], nsis [for .exe auto-installer].



=== Linux 64-bit ===

If you are on Linux '''64-bit''', you '''MUST''' remove some files:

  $ rm -f ../i586-mingw32msvc/bin/moc ../i586-mingw32msvc/bin/uic ../i586-mingw32msvc/bin/rcc

In addition, install the ''qt4-tools'' package.

=== Fix your contrib path ===

If your Mingw prefix is not ''i586-mingw32msvc'' (you are NOT on Debian or Ubuntu), create a symlink to contribs:

=== 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 <code>./configure</code> script. 

Create a subfolder:
  $ mkdir win32 && cd win32

Use the standard configuration: 
 $ ../extras/package/win32/configure.sh --host=i586-mingw32msvc
'''NB''': use '''YOUR''' Xcompiling prefix here, like ''i486-mingw32''


Alternatively, you can run configure manually:
 $ ../configure --host=i586-mingw32msvc
See <code>'../configure --help'</code> 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.

You may also add the ndis tools and everything needed by the <code>make package-win32*</code> targets:
<pre>
sudo yum --verbose --noplugins install \
mingw32-nsiswrapper \
mingw32-nsis \
zip \
p7zip \ 
lua


Use 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 (might be package-win32-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!