= Compiling KMess for Windows = This is a complete howto to compile KMess 2 for Windows. Notes: * this is alpha software, and in the end we want to provide a simple installer you can double-click on. Until then, you'll have to run through these steps manually. * You'll also have to install additional software so KDE 4 software can be compiled at Windows. That's what makes this tutorial extra long. == Setting up the KDE runtime == You need to following tools: * [http://www.winkde.org/pub/kde/ports/win32/installer/kdewin-installer-gui-latest.exe KDE Installer] for Windows, see [http://techbase.kde.org/Projects/KDE_on_Windows/Installation KDE techbase] for more info. Notes for the KDE installer: * The KDE installer should be kept in some program folder (e.g. `C:\KDE4`) can you can run it again to install more KDE software. * It's recommended to use paths without spaces for all install paths (e.g. `C:\KDE4`). * Follow the [http://techbase.kde.org/Projects/KDE_on_Windows/Installation#Summary_of_Steps instructions] * In the first setup, uncheck ''Skip basic settings'', choose the developer version and MinGW compiler edition (unless you have Visual Studio installed too off course). From the installer, you can select appliation, e.g. `kate` (an editor like Textpad). The minimal to install is: * KDE: `kdelibs`, `kdebase-runtime`. When prompted for file locations, you can enter: * `C:\KDE4` for KDE 4. Using spaces in the paths, like `C:\Program Files\KDE4` could cause problems compiling the handbook and icon resources. This is a bug in KDE 4. Now try to run a KDE 4 application: * ''Start'' -> ''KDE 4.x release'' -> ''Utilities'' -> ''Kate'' The first startup takes ~1 minute, and then a Kate dialog should appear! == The compiler setup == You need to install the following tools: * [http://sourceforge.net/projects/mingw/files/Automated%20MinGW%20Installer/ MinGW compiler], to build the KMess `.exe` file. * A Git client, this can either be: * [http://code.google.com/p/tortoisegit/ TortoiseGit] + [http://code.google.com/p/msysgit/ msysGit] * [http://code.google.com/p/gitextensions/ GitExtensions] This installer has msysGit bundled. TortoiseGit has the advantage of integration with the Windows Explorer. GitExtensions on the other hand offers a clear overview of all commits, and displays helpful prompts. This makes it easier to understand and use Git. For the MinGW install, consider using `C:\MinGW as this needs to be retyped with every MinGW installer... Run the KDE installer, and enable the following software: * devel-tools: `cmake`, `doxygen`, * KDE: kdelibs ''(+devel option)'' * kdesupport: `automoc`, * qt: qt ''(+devel option)'' * tools: `mingw-utils`, `perl`. * win32libs: `libxml2`, `libxslt2` ''(+devel options)'' Also recommended to install: * KDE: `kate` (a code editor, works a bit like TextPad) * debug-tools: all of these * tools: `findutils`, `grep` (to really search in all files). To compile KDE applications, add the folders to the system PATH: * Go to: ''Start'' -> ''Control Panel'' -> ''System'' -> ''Advanced'' -> ''Environment Variables''. * To the user variables, add `KDEDIRS` with the value `C:\KDE4` and `KDEDIR` with the same value `C:KDE4`. * To the system variables, search for `PATH`, and append the following: `;C:\KDE4\bin;C:\KDE4\lib;C:\MinGW\bin` Now you should be able to run apps from the command line too. == Accessing KMess from Git == To download the KMess sourcecode, use: * For TortoiseGit: * Create a folder, e.g. `C:\development`. * Right click on it, choose `Git Clone...` * Enter as URL: `git://gitorious.org/kmess/kmess.git` * Press OK. * Now navigate to `contrib\isf-qt`, right click and select `TortoiseGit` -> `Submodule update` * For GitExtensions: * In the left sidebar, select `Clone repository` * Enter as URL: `git://gitorious.org/kmess/kmess.git` * Select the proper location, and press "Clone". * Press "Yes" again when prompted to update the submodules. Note again spaces in the paths give problems with compiling software ([http://bugs.kde.org/show_bug.cgi?id=163440 KDE #163440]). Since the Desktop folder is actually `C:\Documents and Settings\you\Desktop` it causes problems as well. Now you have the code, and you can build it. To generate the build instructions, do: * Open a command prompt window. * Navigate to the `kmess2` directory. * run the following commands: {{{ mkdir build cd build cmake -D CMAKE_INSTALL_PREFIX=C:\KDE4 -D CMAKE_BUILD_TYPE=debugfull -D KMESS_DEBUG_OUTPUT=1 -G "MinGW Makefiles" .. }}} * (If you don't want a full debug build, run this command instead of the above cmake command:) {{{ cmake -G "MinGW Makefiles" .. }}} * If everything went well, type: {{{ mingw32-make }}} * And then: {{{ mingw32-make install }}} KMess should now be installed. ---- = Appendices = == Compiling qca2 == Before compiling qca2, copy your ssleay32.dll file in KDE4/bin to libssl32.dll. Since QCA2 is broken in the latest release of KDE 4 as of 31-03-2009, you need to build qca2 yourself. Use the instructions from http://techbase.kde.org/Getting_Started/Build/KDE4/Windows/Building_KDESupport_Libraries#qca to checkout kdesupport (or qca only maybe), compile (use CMAKE_BUILD_TYPE=Release instead of Debug!) and install it. This is non-ideal and has to be done because of a bug in the latest installer; which seems to ship with the debug version of qca2 and the release version of the KDE libs itself. Maybe this won't be needed for you; try running 'qcatool2 plugins'; if you see qca2-ossl listed under "Available providers", you're set. After installing qca2, re-run qcatool2 plugins to see if it's correctly installed. After that, run KMess and you should be able to log in. == Manual things to fix (temporary) == If you get errors like: {{{ C:/MinGW/include/winbase.h:1663: error: declaration of C function `LONG InterlockedCompareExchange(volatile LONG*, LONG, LONG)' conflicts with C:/KDE4/include/QtCore/qatomic_windows.h:387: error: previous declaration 'long int InterlockedCompareExchange(long int*, long int, long int)' here }}} You probably had MingW installed on your PC and the KDE installer updated it. In such cases, try to get this installation of MingW and install it over your current one... [http://digikam3rdparty.free.fr/misc.tarballs/MinGW5.1.4ok] This is, however, completely unsupported or anything - that may as well break your PC. Reference: [http://mail.kde.org/pipermail/digikam-users/2008-November/006657.html] As of 2009-03-30, build.make still has references to D:/kde/kde-mingw. The .bat file supplied by Diederik still works, but you should edit it to replace the paths if needed. Also, after running it, re-run cmake or edit the Makefile and CMakeFileskmess.dirlink.txt. This is what Diederik wrote back in May 2008: Unfortunately, some things are went wrong (2008-05-12). The following things had to be fixed: * building the handbook failed if there are spaces in the paths. Run `mingw32-make VERBOSE=1` to see the actual command which fails. Copy this to a new Command Prompt window to run the proper command manually (with `C:Progra~1..`). * The file `build/src/CMakeFiles/kmess.dir/build.make` had references to `D:/kde/kde-mingw`, manually replaced those with `C:/Program Files/KDE4` ([http://bugs.kde.org/show_bug.cgi?id=163438 KDE #163438]). * If the PATH contains references to Gtk / Gimp it could cause DLL conflicts in `libxml2` at KMess startup ([http://bugs.kde.org/show_bug.cgi?id=164170 KDE #164170]). Update `kmess.exe.bat`, and remove those paths from there. Another option is putting the KDE4 directories at the start of the windows PATH variable. This way, the KDE4 DLL's are picked up first. To fix the first two problems automatically, download the `makefix.bat` file attached at the bottom. * Save the file in your build directory. * Open the file in an editor, and change the paths to the KMess folders. * type `makefix` in your console window to run it. == Getting debugging to work == To view the debug output, you need to have DebugView (`dbgview`) open. This program can be installed from the "KDE Installer for Windows". To get good debug output in the DebugView program by Sysinternals, after making sure you correctly set debugfull and everything in the build options, you need to edit two files: * include/kdebug.h in your KDE directory: comment out line 38 to 48 (the lines about KDE_NO_DEBUG_OUTPUT and KDE_NO_WARNING_OUTPUT. * kmessapplication.cpp: comment out line 53, the debug handler. This will make the kmess debugging messages appear correctly in the DebugView program. == Resizing the command line window == Right-click on the title bar of the command prompt, and look for the buffer size options. When the width is increased, the command line can become much bigger as well. == Comparing files == It's highly recommended to install [http://www.winmerge.org WinMerge]. This also integrates with TortoiseSVN, so you'll be able to compare files easily. WinMerge converts end-of-line characters to Windows format by default. You'll have to disable this option in the settings at: ''Edit'' -> ''Options'' -> ''Editor'' -> ''Preserve orginal EOL chars''. == Applying patch files == It's possible to merge two files using TortoiseGit. Right click on the root folder, and select ''TortoiseGit'' -> ''Apply patch...''. In the editor, use the ''Save'' button to apply the changes to one file. When you hit ''Reload'' you'll see both files are identical now. Command line users will find that the KDE Installer offers a package for the `patch` command.