|Note: This page is about KDE 4. It isn't applicable for KDE 3 development.|
|This section needs improvements: Please help us to
cleanup confusing sections and fix sections which contain a todo
This page has been moved out of kdelibs.com wiki page.
This step-by-step tutorial shows how to get the current kdelibs from the upcoming KDE4 based on Qt4 compiled under Microsoft Windows.
This is a program that lets you easily install all the requirements for building kdelibs. It also has a list of tools in its list that are helpful and needed, like the mingw compiler suite, subversion clients, debugging tools and so on.
The kdewin-installer is available in a GUI and console-only form from the kdewin-installer download page.
For the GUI version: If you are running the Installer for the first time, you should have a look in the Settings page (klick on the button 'Settings'). You can select another installation directory if you want. I suggest to choose one that has no spaces in it for now, as it seems some parts of the kde4 buildsystem have problems with that. Choose the compiler you use and accept the Settings.
You'll see a tree of all available packages on the right side. In that tree select kdesupport-mingw and win32libs in the all category under the dependecies subtree. This should select all packages that are needed to build kdelibs.
Additionally you might want to select the MinGW, cmake, TortoiseSVN, mingw-utils and zip package from the tools category if you haven't already installed those.
After clicking on 'Finish' the installer will download and install the packages. For mingw, cmake and tortoise it only downloads and starts an installer executable so expect more installation dialogs from those.
MinGW (Minimalist GNU for Windows) contains the GNU Compiler Collection (gcc) for MS Windows. You can either download it directly from here or you select the package in the installer.
CMake is the make tool used by KDE.
Install cmake in a path without spaces to avoid troubles (at least under win2k).
win32libs contains a collection of libraries not available by default on Windows. See 3rd-party libraries required for KDElibs 4.
These libraries have to be installed:
This library shouldn't be installed with the installer, you should rather compile it yourself.
This Framework can be downloaded with the installer, or you can build it on your own.
There are several libraries which will be required for building kdelibs. You may want to compile them yourself or simply download them using the KDEWin-Installer. You will need:
The next step is setting up a proper environment to build KDE4 applications. This includes setting the PATH variable and some additional variables needed for CMake and running KDE applications.
The path C:\kde4\win32libs is used as the installation directory from the kdewin-installer, C:\kde4\kdelibs-install as the path where all kde4 modules will be installed to. Obviously you have to change the actual values to suite your system. The Sources from SVN reside in C:\kde4\kdelibs-src. Create a file and name it environment.bat:
@echo off set MYKDEDIR= :: enviroment.bat should be able to autodetect the following values :: only set them manually, if the script complains about them :: don't use quotes (") ! :: Microsoft Platform SDK install directory :: set MSPSDKDIR=C:\Program Files\Microsoft Platform SDK for Windows Server 2003 R2 :: CMake install directory :: set CMAKEROOT=C:\Program Files\CMake 2.4 :: make only changes below this line, if you know, what you are doing if "%KDEDIR%" equ "" ( set KDEDIR=%MYKDEDIR% ) if "%KDEDIR%" equ "" ( echo KDEDIR not set echo set MYKDEDIR in %0% or KDEDIR at the enviroment goto ERROR ) if "%MSPSDKDIR%" equ "" ( for /F "usebackq tokens=3 delims= " %%i in (`@reg query "HKLM\SOFTWARE\Microsoft\MicrosoftSDK\InstalledSDKs\D2FF9F89-8AA2-4373-8A31-C838BF4DBBE1" /v "Install Dir"`) DO ( set MSPSDKDIR=%%i ) ) if "%MSPSDKDIR%" equ "" ( echo can't detect the Microsoft Platform SDK install directory echo set it at the start of %0% or with the MSPSDKDIR enviroment variable goto ERROR ) if not exist "%MSPSDKDIR%\include\windows.h" ( echo can't find windows.h in %MSPSDKDIR%\include\ echo try to set the Microsoft Platform SDK install directory at the start of %0% or with the MSPSDKDIR enviroment variable goto ERROR ) if "%CMAKEROOT%" equ "" ( for /F "usebackq tokens=3 delims= " %%i in (`reg query "HKLM\SOFTWARE\Kitware\CMake 2.4.6" /ve`) DO ( set CMAKEROOT=%%i ) ) if "%CMAKEROOT%" equ "" ( echo can't detect the cmake root directory echo set it at the start of %0% or with the CMAKEROOT enviroment variable goto ERROR ) if not exist "%CMAKEROOT%\bin\cmake.exe" ( echo can't find cmake.exe in %CMAKEROOT%\bin echo set it at the start of %0% or with the CMAKEROOT enviroment variable goto ERROR ) if "%VS80COMNTOOLS%" equ "" ( echo can't find the Microsoft Visual Studio installation directory echo set the VS80COMNTOOLS enviroment variable goto ERROR ) echo psdk: %MSPSDKDIR% echo cmake: %CMAKEROOT% set PATH=%KDEDIR%\bin;%PATH%;%CMAKEROOT%\bin;%MSPSDKDIR%\bin set DBUSDIR=%KDEDIR% set QTDIR=%KDEDIR% set KDEWIN_DIR=%KDEDIR% set KDEWIN32DIR=%KDEDIR% set INCLUDE=%PSDKDIR%\include;%KDEDIR%\include set LIB=%PSDKDIR%\lib;%KDEDIR%\lib set CMAKE_INCLUDE_PATH=%INCLUDE% set CMAKE_LIBRARY_PATH=%LIB% call "%VS80COMNTOOLS%vsvars32.bat" cmd.exe goto END :ERROR pause :END
take out the following paragraph:Create a file environment.bat and add the following lines:
@set SOURCE_PATH=C:\kde4\kdelibs-src @set INSTALL_PATH=C:\kde4\kdelibs-install @set UTILS_PATH=C:\kde4\win32libs @set DBUSDIR=%UTILS_PATH% @set KDEDIRS=%UTILS_PATH%;%INSTALL_PATH% @set KDEWIN_DIR=%UTILS_PATH% @set PATH=%PATH%;%UTILS_PATH%\bin;%INSTALL_PATH%\bin;%INSTALL_PATH%\lib @set QT_PLUGIN_PATH=%INSTALL_PATH%\lib\kde4\plugins;%UTILS_PATH%\plugins @set STRIGI_HOME=%UTILS_PATH% @set XDG_DATA_DIRS=%UTILS_PATH%\share;%INSTALL_PATH%\share
You will have to run this file every time you start a new cmd-shell. If you don't want to run this file you can make the variable entries permanent: Open up the control panel and select the System Entry. Then go to the Extended tab and select Environment Variables. In the section titled 'user variables' add the above entries. You should have cmake and mingw32-make etc. in your path as well.
svn://anonsvn.kde.org/home/kde/trunk/KDE/kdelibsinto the dedicated source directory.
Afterwards create a new subdirectory inside the kdelibs source directory named build. Then open a command console, select Start->Run Command and type cmd into the field. Then navigate to the just created build directory.
The next step is running CMake. For an easy start just run (Using the installation directory that was set in the environment variables section):
cmake -G "MinGW Makefiles" .. -DCMAKE_INSTALL_PREFIX=%INSTALL_PATH%\ -DCMAKE_INCLUDE_PATH=%UTILS_PATH%\include -DCMAKE_LIBRARY_PATH=%UTILS_PATH%\lib
This command should appear in just one line. Make sure that the paths contain no trailing "\".
You can set other CMake variables in the same way, also interesting might be to create a debug build. This can be achieved by adding -DCMAKE_BUILD_TYPE=Debug.Now you can let MinGW build and install the module by issuing
mingw32-make mingw32-make install
This will take some time.
The process for building other modules that contain applications that are of interest for you is the same as the process you've just done for kdelibs. There might be additional requirements for some KDE4 modules that you have to build first, in particular kdebase might be required (which in turn requires kdepimlibs).
This can be done from the same command window where you've built KDE4. Just type the application name and hit enter. This should automatically start all kde4 daemons and dbus which are required to run for kde4 applications.
For example after building and installing both kdevplatform and kdevelop module the KDevelop4 IDE can be started by executing kdevelop. If you get some errors about missing DLLs, make sure that all DLLs are set up in your PATH variable. You can add the path either by changing the environment variables over the control panel (be sure to restart cmd.exe!) or by entering (if C:\example\path\to\dll\lib is the location of the dll):