
        KVIrc4 win32 compiling howto (WIP)
        by CtrlAltCa

This paper describes how to successfully compile a working copy ok KVIrc4 under Microsoft Windows operating systems.



Requisites:

  - A Microsoft Windows operating system:
      [Needed to run KVIrc into, mandatory]
      2000, preferably with service pack 4
      xp, preferably with at least service pack 2
      vista, preferably not :p

      Notice: dos-based Windows operating system (95,98,98se,me) are not officially supported by KVIrc.
      Anyway, if you're still using such an old os, you've worst problems than this...

  - CMake from Kitware:
      [Configuration tool; needed to compile KVIrc, mandatory]
      Download it from http://www.cmake.org
      The package you want is called "Windows (Win32 Installer) cmake-2.6.1-win32-x86.exe" (version number may vary).
      You need at least version 2.6 to compile KVirc.

  - Qt 4 from Trolltech:
      [Graphic library, mandatory]
      Download it from http://trolltech.com/developer/downloads/qt/windows
      The package you want is called "qt-win-opensource-4.4.3-mingw.exe" (version number may vary).
      You need at least Qt 4.4 upwards.

  - MinGW from the MinGW team:
      [Compiler; needed to compile KVIrc, mandatory]
      While installing Qt4, you will be asked to perform a minimal install of MinGW; you can simply answer 'yes' to get this installed.
      MinGW is still based on the 3.x brach of gcc; if you want to test the new gcc4 (it should create faster executables), follow these
      instructions:
      Point your browset at: http://sourceforge.net/projects/mingw/ , follow the "download" link and get the "Automated MinGW Installer MinGW 5.1.4" (version number may vary) and the "GCC Version 4 Testing: gcc-4.3.0-20080502-mingw32-alpha" packages (version may vary). First execute the automated installer, then uncompress the gcc4 archive and copy it over the installation directory created by the installer (overwriting the old gcc3). You can also use TDM's GCC/mingw32 Builds (these unofficial mingw packages ships with gcc4 included) you can find here: http://www.tdragon.net/recentgcc/.
      Beware that the current Qt version (4.4.3) is packing some old win32api headers, that brakes compilation with gcc4. You can read more info about
      this issue here: http://www.qtcentre.org/forum/f-installation-and-deployment-5/t-building-qt-443-with-gcc-432-on-windows-xp-16697.html

  - OpenSSL compiled for Win32 from Shining Light Productions:
      [Enc/Decrypt library; needed to secure your irc sessions, optional]
      Download it from http://www.slproweb.com/products/Win32OpenSSL.html
      The package you want is called "Win32 OpenSSL v0.9.8g" (version number may vary; there should be a notice like "Recommended for software developers" in the package description).
      Any recent version should work; general rule: more recent means more secure.
      Note: probably GnuWin32's version (see infos for Zlib) works too.

  - Zlib compiled for Win32:
      [Compression library; needed for many stuffs, optional]
      Many projects create win32 versions of zlib; a part of them support MinGW too. You can find a working version on GnuWin32's project website: http://gnuwin32.sourceforge.net/packages/zlib.htm .
      The package you want is "Complete package, except sources" (version number may vary).

  - Perl for Win32:
      [Programming language; needed for documentation creation and optional scripting support, mandatory by now]
      Any win32 version will work; We advice you to use the version you can find at http://www.activestate.com/store/activeperl/download .

  - GNU GetText for Win32:
      [Localization library; needed to translate kvirc interface into your own language, optional]
      Any version will work; We advice you to use the version you can find at http://sourceforge.net/projects/gettext .
      The package you want is called "gettext-tools-0.13.1.bin.woe32.zip", "gettext-runtime-0.13.1.bin.woe32.zip" and "libiconv-1.9.1.bin.woe32.zip" (version numbers may vary).

  - Phonon smplayer/vlc frontend for MinGW:
      [Multimedia library; needed to play multimedia files using phonon, optional]
      (For the little story, the default Windows backend for Phonon is based on DirectShow 9 and MinGW is not capable of compiling DS9 code, that's why Trolltech doesn't ship Phonon with Qt-4.4 MinGW)
      Get it at http://code.google.com/p/phonon-vlc-mplayer/; it needs some tweaking to work;
      Please refer to the "Getting phonon to work with mplayer frontend" at the end of this document.

Further reccomended download if you plan to develop KVIrc:

  - GNU Debugger (gdb) for Win32:
      [Dev Tool: Debugger; optional]
      Download if from the MinGW website.

  - StraceNT (aka strace for Win32)
      [Dev Tool: tracer; optional]
      Download it from http://www.intellectualheaven.com/ .



Builder chain installation:

First install CMake and Qt4. If you don't have already a MinGW working installation, be sure to accept the installation of a minimal MinGW offered by the Qt4 setup.
Then install the rest of the packages. Remember to write down the installation paths of the packages: you'll need them later.

Now you have to define some environmental variable:

  CMAKE_INCLUDE_PATH
  Set it to the include subdirectories of the paths where you installed mingw, zlib and openssl. Example: 
  C:\ZLIB\INCLUDE;C:\MINGW\INCLUDE;C:\openssl\include

  CMAKE_LIBRARY_PATH
  Set it to the libs subdirectories of the paths where you installed mingw, zlib. If the library packages you are using support several compilers, be sure you're including the right libraries directory (tipically named MinGW). Add c:\windows\system32 too (the path to the system32 durectory of your windows installation). Example:
  C:\ZLIB\LIB;C:\MINGW\LIB;C:\openssl\lib\mingw;c:\windows\system32

  PATH
  Add to the system PATH the bin directories of CMake, Qt, MinGW. If you plan to use gdb and/or straceNT, add their bin directories too. Example:
  C:\Programmi\CMake 2.6\bin;C:\QT\4.4.0\BIN\;C:\MINGW\BIN


Now you should be ready to compile KVIrc.



Compilation

Download KVIrc sources from KVIrc's website, a mirror or using svn (see instructions on KVIrc website about how to do that).
Using CMake we are able to compile the project in-sources or out-of-sources; we'll go with the second option, that keeps the source directories untouched without filling them with compiled objects and cmake definition files.
So we have to create a directory where to compile KVIrc into, and run cmake inside that dir, passing to cmake the dir containing kvirc sources as a parameter (and any other option).

Example:
  - download kvirc's trunk from svn into c:\kvirc
  - create directory c:\kvirc\build
  - open a command promp, browse to "c:\kvirc\build" and run "cmake .. " (without quotes; .. refers to the parent directory, c:\kvirc, that contains kvirc source code); alternatively, use the cmake gui specifing "c:\kvirc\" as "where is the source code" and "c:\kvirc\build" as "where to build the binaries" and press "configure".
  - cmake will check your system and create a set of Makefiles you'll need later to compile KVIrc. If it's complaining about some missing library it can't find, probably you haven't setted up properly the environmental variables needed. Refers to the errors to understand what you need to fix.
  - once you get cmake to create the complete set of Makefiles, simply exec a "make" (exactly as used to do under unix); KVIrc will start to get compiled.
  - once the compilation ends, exec a "make install" (exactly as you use to do under unix); the installation system should create a "release" directory (in our example: c:\kvirc\build\release) and move kvirc compiled binaries in there.
  - simply running kvirc from that directory should work :) . If instead it's complaining of some missing dll's, you may need to copy those dlls into kvirc binary directory (in our example: c:\kvirc\build\release) or to get those dlls recognized and loaded automatically from you o.s.



Common errors, pitfalls, ..
- Currently we're double #define'ing some things, this causes some warnings like this one:
  ----------
  C:\kvirctrunk\src\kvirc\kvs\kvi_kvs_corefunctions.cpp:25:1: warning: "__KVIRC__" redefined
  <command line>:15:1: warning: this is the location of the previous definition
  ----------
  This is a simple warning, it doesn't block compilation or affects any functionality.

- Rijndael module isn't compiling/loading/working at all:
  It is excluded from the mingw port by now, because it uses class templates and virtual functions in a way gcc 3 () can't understand well.

- On modules compilation we get a warning like this one:
  ----------
  C:\kvirctrunk\src\modules\clock\libkviclock.cpp:242: warning: `KVIrc_module_info' initialized and declared `extern'
  ----------
  This is a simple warning, it doesn't block compilation or affects any functionality.

- During the compilation, we get some errors like this one:
  ----------
  C:/kvirctrunk/src/kvilib/system/kvi_time.h:0: Warning: No relevant classes found. No output generated.
  ----------
  In the compilation we call qt's moc to parse headers files and expand qt macros; that warning simply means that moc found nothing to expand in that header file. We can fix this removing headers that doesn't need to be moc-ed from the lists in CMakeLists.txt.



Getting phonon to work with mplayer frontend

- Install all needed requirements, including at least one of these players:
  Smplayer: get it from http://smplayer.sourceforge.net/ (works, tested with kvirc)
  VideoLAN: you need to use svn version; more info at http://www.videolan.org/ (untested with kvirc)
  Please note that to use the mplayer backend you have to install smplayer to C:\Program Files\SMPlayer\ . If your are using a not-english localized version of windows, you'll probably need to change the proposed path to this one during installation.
- Get latest phonon-vlc-mplayer source from svn
- This frontend wants to install the mingwm10.dll library in its binary output directory; you'll probably need to fit the default path in trunk/CMakelists.txt from 
  install(FILES C:/mingw/bin/mingwm10.dll DESTINATION ${BIN_INSTALL_DIR})
  to the right path where you have installed mingw in your system.
- go to /trunk/build/ and run:
  run build_mingw-release.bat
  mingw32-make
  mingw32-make install
- now you can copy compiled files from /trunk/build/win32-mingw-release/:
  copy phonon.dll to QTDIR/bin and libphonon.dll.a to QTDIR/lib
- in /trunk/build/win32-mingw-release/phonon_backend you find the backends for vlc and mplayer;
  in the directory containing kvirc.exe create a subdirectory "phonon_backend" and copy phonon_mplayer.dll into it
