Welcome, Guest! Log In | Create Account

Building on Windows

From smplayer

Jump to: navigation, search

It's not unusual that Linux users had to compile a program by themselves sometimes, but that's uncommon for Windows users.

Why compiling it?

There are several reasons:

  • be able to use the latest version without having to wait for the binary update.
  • modify the source code. You might need to make some small modification in the application.
  • get a statically linked binary, without dependencies on the Qt dlls

Compiling a program on Windows originally created under Linux can be difficult. For example, compiling mplayer is a hard task, a lot of packages have to be installed and compiled.

Fortunately compiling a Qt program is quite easy.

Contents

Installing Dependencies

Qt Toolkit

First you need to download and install Qt (OpenSource edition) in your computer. You can get a package with installer from http://www.qtsoftware.com/downloads During the installation it will ask you for a compiler. Simply let the Qt installer to download and install MinGW.

Once the installation has finished it will probably will show you some Qt examples, so you can see how cute they are.

Now we're ready to compile smplayer (or any other Qt application). Download the sources (either the *.tar.gz or from the svn) and uncompress them for example in C:\smplayer.

The next step is to open the Qt console: select the option "Qt 4.5.1 Command Prompt" that you'll find under the Qt menu.

That'll open a DOS-like window. Type the following commands:

cd c:\smplayer
compile_windows.bat
Compiling will start. That'll take a few minutes (in my computer less than 2 minutes).

After that you'll get the new compiled smplayer.exe under c:\smplayer\src\release subdirectory.

You'll see that if you try to open it by double clicking on it, it won't work because it can find the Qt dlls. I assume you already have smplayer properly installed in some place, just copy the new smplayer.exe to that directory, replacing the old one. Now it will work.

You may also need to copy the updated translation files (*.qm) from the translations subdirectory.

Libqxt

From version r1176 is possible to compile SMPlayer with Qxt support. Qxt is a library which provides several new classes. SMPlayer will use QxtFileLock for a lock file in main.cpp. That should help to prevent that several instances of SMPlayer would run if lauched at almost the same time (which is done in Windows when selecting the "Enqueue in SMPlayer").

Using Qxt is optional. Without it SMPlayer will just use the old code for the lock file (which may fail sometimes).

First the instructions for Windows (it's easier):

(I assume you already have everything setup to compile smplayer)

Download libqxt-0.4.tar.gz and uncompress libqxt-0.4 in a folder without spaces in its name (otherwise installing will fail!), for instance in C:\Temp\libqxt-0.4

Open the Qt console and type:

cd C:\Temp\libqxt-0.4
configure.bat -release
make
make install

By default Qxt will be installed in C:\libqxt

Now you can remove the folder C:\Temp\libqxt-0.4 if you want.

In the Qt console, go to the folder where you have the smplayer sources:

clean_windows.bat
compile_windows_with_qxt.bat

That's it.

Don't forget to copy QxtCore.dll (from C:\libqxt\lib) to the smplayer.exe folder.

zlib

The possibility to download subtitles in zip format and uncompress them (added in r1989), makes a little bit more complicated to build smplayer on Windows.

Now it's necessary to compile zlib first. This is how:

  • Download the source code: http://www.zlib.net/zlib-1.2.3.tar.gz
  • Uncompress it (for example in c:\development\zlib-1.2.3).
  • Open the "Qt Command Prompt" and cd to that directory.
  • Compile it with
make -fwin32\makefile.gcc

Now you can compile smplayer as usual, but just one thing: by default it will look for zlib in c:\development\zlib-1.2.3, if you installed it in another folder you'll have to edit src/smplayer.pro and change the path.

Compiling SMPlayer Statically

A static build will not depend on the Qt dlls (QtCore4.dll, QtGui4.dll, QtNetwork4.dll and mingw10.dll). Also the application can startup faster.

The following steps I'm telling from memory, so I'm not sure if they are 100% accurate. If someone tries, please tell if it works.

Actually compiling smplayer is the same, nothing changes. But Qt itself has to be statically compiled.

Assuming you have Qt installed in C:\Qt\4.5.1:

  • open the "Qt 4.5.1 Command Prompt" in the Windows menu. The current directory should be already C:\Qt\4.3.2, if not, change to it:
cd C:\Qt\4.5.1
  • now type:
configure -static -release -no-exceptions

That will take some minutes.

  • and finally we compile Qt:
make sub-src

That will take about 15-20 minutes to complete.

If everything is ok you'll have Qt compiled statically.

This process has to be done only once!

Now, when you compile smplayer (or any other Qt application) it will create a static binary.

If you have compiled smplayer before, it's recommended to clean the directory tree before recompiling: (assuming you've got the sources in c:\smplayer)

cd c:\smplayer
clean_windows.bat

Now you can compile smplayer as usual:

compile_windows.bat

Now the binary should be bigger, about 7 or 8 MB size, but it should run without the dlls.

Creating a Windows Installer

smplayer-installer.nsi is the script for NSIS (Nullsoft Scriptable Install System), which allows to create the installer for Windows. This script requires requires NSIS 2.x available freely from http://nsis.sourceforge.net. From SVN r3288 and later, the script must be compiled with Unicode NSIS version 2.45. It is intended to be ran one directory up from 'smplayer-build'.

The SMPlayer NSIS script is set up to compile two different setups:

  • SMPlayer including MPlayer files
  • SMPlayer that downloads MPlayer from Sourceforge

Downloading MPlayer during install is the default mode. To create an installer with the MPlayer files you need to define WITH_MPLAYER in the compiler. You need to have the smplayer-build\mplayer files present (not included in SVN):

makensis.exe /DWITH_MPLAYER smplayer-installer.nsi

MakeNSISW (GUI Compiler): Tools -> Settings. Add WITH_MPLAYER in Symbol Name and add to the list. Leave the Value field blank.

MakeNSISW

Other required files:

May also be found @ ftp://ftp.berlios.de/pub/smplayer/tools/nsis/

Other required defines w/ values:

  • VER_MAJOR
  • VER_MINOR
  • VER_BUILD
  • VER_REVISION (only if non-zero)

Example, to build v0.6.8 that includes MPlayer files using the command-line compiler:

C:\Program Files\NSIS\Unicode\makensis.exe /DWITH_MPLAYER /DVER_MAJOR=0 /DVER_MINOR=6 /DVER_BUILD=8 smplayer-installer.nsi