KDE LogoKDElibs.com
Cross-platform KDE Development











Building KDElibs 4 using GCC and MinGW with Qt 4.2 the Complex Way

This tutorial is UNDER PROGRESS

Table of contents

Introduction

This step-by-step tutorial shows how to get the current kdelibs from the upcoming KDE4 based on Qt4 compiled under Microsoft Windows.

Installing cmake

Informations about installing cmake could be found here (http://wiki.kde.org/tiki-index.php?page=KDECMakeIntro) I used the precompiled version of cmake 2.4.5 (http://www.cmake.org/files/v2.4/cmake-2.4.5-win32-x86.exe).

Installing subversion client

Subversion is required to access KDE source repositories. I used here the command line tools (http://subversion.tigris.org/files/documents/15/34093/svn-1.4.0-setup.exe).

Installing Perl

Perl is required because new dcopidl and other scripts depends on perl. I used here the Latest stable version (http://downloads.activestate.com/ActivePerl/Windows/5.8/ActivePerl-5.8.8.819-MSWin32-x86-267479.msi).

Installing Win32libs

win32libs contains a collection of libraries not available by default on Windows. See 3rd-party libraries required for KDElibs 4.

Compile and install WinDBUS

Download the latest winDBus sources (http://sourceforge.net/project/showfiles.php?group_id=171968) (which are already patched) and extract them into "C:\svn\windbus" or get the latest svn sources (http://sourceforge.net/svn/?group_id=171968)

cd c:\svn\windbus
patch -p0 < DBus-win32.patch
cd ..
mkdir windbus-build
cd windbus-build
cmake -G "MinGW Makefiles" ..\windbus\cmake\
mingw32-make
mingw32-make install

patch is the GNU patch available on http://gnuwin32.sf.net

If cmake fails cause it was not able to find libxml2, you may like to try something like; cmake -G "MinGW Makefiles" -DDBUS_USE_EXPAT=OFF -DLIBXML2_INCLUDE_DIR=C:\Programme\win32libs\include -DLIBXML2_LIBRARIES=C:\Programme\win32libs\lib\libxml2

Also I am not sure if -DDBUS_INSTALL_SYSTEM_LIBS=ON is required. At least for me it worked without so far...

Installing Qt Library

Download and install the latest Qt 4.3.x source or binary package (you need to recompile Qt as it isn't shipped with qdbus support. I used here Qt 4.3.0 (ftp://ftp.trolltech.com/pub/qt/source/qt-win-opensource-4.3.0-mingw.exe).

Compile Qt with the following command line parameters

configure -openssl -I "<path to openssl headers>" -L "<path to openssl libs>" \
-qdbus -I "<path to windbus headers>" -L "<path to windbus libs>"

Setting up environment

Now the question is, how what your environment-variables look like. You probaly need to change them to point to the correct locations. Mine look like ( print them by "PATH"+Enter in the commandline, set them with "set PATH=..."+Enter );

set PATH=C:\Perl\bin\;%PATH%
set PATH=C:\MinGW\bin;%PATH%
set PATH=C:\Qt\4.2.1\bin;%PATH%
set PATH=C:\Programme\CMake\bin;%PATH%
set PATH=C:\Programme\Subversion\bin;%PATH%
set PATH=C:\Programme\kdewin32\bin;%PATH%
set PATH=C:\Programme\win32libs\bin;%PATH%
set CMAKE_INCLUDE_PATH=C:\Programme\win32libs\include
set CMAKE_LIBRARY_PATH=C:\Programme\win32libs\lib

You should consider to have those definitions permanent defined in your system by adding them to the System=>Extended=>Environmentvariables=>Systemvariables.

Compile and install KDEWin32

On windows KDE requires a special supplemental library named kdewin32. We need to checkout this library and compile it before we are able to start to compile kdelibs:

cd c:\svn
mkdir kdewin32
cd c:\svn\kdewin32
svn co svn://anonsvn.kde.org/home/kde/trunk/kdesupport/kdewin32
cd kdesupport\kdewin32
cmake -G "MinGW Makefiles"
mingw32-make
mingw32-make install

This will compile and install the library in c:\Programme\kdewin32.

Compile some libs from kdesupport

You'll need some more libs which are located in http://websvn.kde.org/trunk/kdesupport/ They're all compilable with cmake (if not, let us know)

  • strigi is needed for kdelibs
  • soprano is also needed, it depends on 'redland' library which is available through the kdewin installer
  • qca2 is needed to compile some apps (like kopete)

Compile and install kdelibs

First we need to get the kdelibs sources. See KDE's developer site how to retrieve the source (http://developer.kde.org/source/). I did following steps within the commandline;

cd c:\svn
svn co svn://anonsvn.kde.org/home/kde/trunk/KDE/kdelibs

Now we are ready to compile the sources by using the following commands;

cd c:\svn
mkdir kdelibs-build
cd kdelibs-build
cmake -G "MinGW Makefiles" ..\kdelibs\
mingw32-make

If you get linking-erros like

Linking CXX shared library ../bin/libkdecore.dll
Creating library file: ../bin/libkdecore.dll.a
CMakeFiles/kdecore.dir/kapplication.obj(.text+0x3d75): In function `ZN12KApplica
tion4initEv':
C:/cvs/kdelibs/kdecore/kapplication.cpp:488: undefined reference to `getuid'
...

a solution may to add to the kdelibs\cmake\modules\FindKDEWIN32.cmake file the line

set(KDEWIN32_LIBRARIES ${KDEWIN32_LIBRARY} msvcrt ws2_32 user32 shell32)