m (moved Distributions with KDE/EasyStartDevelopmentOnDebian to Getting Started/EasyStartDevelopmentOnDebian: was in wrong place)
m (moved Getting Started/EasyStartDevelopmentOnDebian to Getting Started/Distributions/Debian/Source: Git reorg)
This tutorial is intented for people who are using Debian, and want to check out or test some idea on existing KDE code without much hassle.
This tutorial shows a way of easily downloading and compiling and running the KDE software that is used on your Debian system.
First you need to add the source repositories to your installation. This is normally done by editing /etc/apt/sources.list as user root and adding a line starting with deb-src:
kdesudo kwrite /etc/apt/sources.list
The easy way is to copy your existing deb line onto a new line, and change deb to deb-src:
In most(all?) of the cases this will work.
Then you must let this change know to the package manager, so do as root:
Now you want to be able to build a certain package, and in this example we will build the kcontrol configuration modules(aka KCM modules) and the application containing them called systemsettings. Let's say we want to see if we can maybe fix some bug in the Display configuration module, which is called randr actually. In debian the package is systemsettings, so first we will get the build dependencies of that package, so do as root:
aptitude build-dep systemsettings
This will download and install all needed dependencies which are some build tools and otherwise mostly packages with -dev at the end of them, which are in most cases a bunch of header files.
Now in your home directory, as a regular user, make a new directory, and go into it:
Now change to user root using su. Now we will get the sources in this directory. Here are the commands
su #give root password
apt-get source systemsettings #downloads the source
chown karel.karel -R * #subsitute "karel" with your own username!
exit #exit the "su" and return to your user
This downloads the source and applies all the debian patches for you. In this case, it downloads kdebase-workspace because the systemsettings code is only a small part of the kdebase-workspace package. Now go into the newly extracted directory. This is kdebase-workspace-4.3.2 in my case.
Now we go into the source directory, and let cmake generate the Makefiles, which are then used by the make command to build the code. This is done like this:
cmake . # don't forget the extra space+point!
cmake-gui . # don't forget the extra space+point!
Now select only the components starting with BUILD_ you want. In my case it was rather the components I'm sure of that I didn't want :). So I ended up with only BUILD_kcontrol and systemsettings and didn't touch any of the other settings below(because I was very afraid of them weird looking ones!). Then click on the Configure button and then on the Generate button. Close the program now. Now we have makefiles that will only build what we chose to build in the cmake-gui program. So now you can execute the make command to start:
Now it is building!
We will now go to the directory of the randr module we want to develop on:
Edit some file, and then rebuild simply by running make again in this directory:
The module is now being rebuilt. Likewise we can change something in a source file in the systemsettings source directory, and rebuild it using make
To have a full rebuild of the code, first do make clean before the make command.
This may be somewhat difficult, but we start easy ;)
You go into the systemsettings/app directory, and there start that self-compiled code like this:
This will indeed run your new code. But it is better to first install it into your /usr/local directory so everything is setup correctly in a certain hierarchy, because the systemsettings program might need to find or access certain files to function properly. You do this with the simple command make install, executed as root in the main directory of the application or module you just built:
However! Here is the difficult part... We already have a systemsettings program installed: the one installed by the Debian system in /usr/bin/systemsettings. So you will now find that we have a second one of our own in /usr/local/bin/systemsettings.
|So remember this: Debian installs everything under /usr and your programs end up under /usr/local|
The make install command copied more than only the executable file! It also copied e.g. /usr/local/lib/kde4/kcm_randr.so. So when we start our "local" systemsettings program, we want to make sure it first finds the files it installed under /usr/local, and not first the files installed by Debian under /usr.
We need to tell our current console session the additional KDE path where it needs to look for services and libraries and programs. This is done by filling in the KDEDIRS environment variable like this:
Now when we start the systemsettings module in this console session it will find the kcontrol configuration module located in /usr/local/lib/kde4/kcm_randr.so before the one in /usr/lib/kde4/kcm_randr.so:
And you will now see your own compiled code in action!
Now you have completed compiling and running your own compiled code, you are ready to check out the other tutorials here and gain some deeper insights!