KDE4's ktimetracker loaded as eclipse project
This describes how to use Eclipse to develop KDE 4 applications. It has been tested with Eclipse Ganymede and SUSE Linux 11.1 but should work same or similar with every combination. As an example KDE application we use KTimeTracker from the kdepim module, other applications should work likewise.
Using this description you will be able to
- update your working copy of KDE source code using the svn command
- build your KDE module using CMake
- build your KDE application from within Eclipse using Make
- compile and run your application with one click from Eclipse
- get auto-completion when editing KDE source code
- have an overview and navigation about your classes within Eclipse
- have call trees for your functions
Set up Eclipse with KDE
- Trying with a virtual machine I had problems starting Eclipse with less than 1 GB RAM. After assigning 3 GB RAM to the virtual machine, Eclipse finally started.
- Download Eclipse IDE for C/C++ developers from http://www.eclipse.org. Unpack it to /home/user/eclipse.
- Download the Eclipse IDE for C/C++ Developers (68 MB) from http://www.eclipse.org/cdt/ and unpack it into your Eclipse folder, in our case /home/user/eclipse.
- As said, we use kdepim as example here. So, download ("checkout") kdepim using git (for advanced git-usage see Development/Git/Configuration, especially URL-Renaming):
git clone git://anongit.kde.org/kdepim
- This will check out into /home/user/kdepim. (Our sample setup for this tutorial)
- Compile kdepim so the usual makefiles are present for all kdepim applications. If you have problems doing this, follow our build instructions.
- Import your project into Eclipse
- Surprise: To import your project, you cannot use "File -> Import". Rather do: File -> New -> C++ Project -> Makefile project -> Empty Project -> un-tag "use default location" -> choose /home/user/kdepim/ktimetracker. Call it "ktimetracker".
- Make sure Project -> Properties -> C/C++ Build -> Builder Settings -> Build location -> Build directory is set correctly.
- Choose Project -> Build Project
- Choose Project -> Properties -> Run/Debug Settings -> New. As project, enter ktimetracker, as C/C++ Application, enter /home/user/kdepim/ktimetracker/ktimetracker. Choose Apply -> Ok -> Ok. Now you can click on the "Run" button and start it.
If you want to integrate the CMake build step into your build toolchain, you will need to
- create a custom builder like this:
echo "cmake . && make -j4 && make install" >/bin/eclipsebuild
chmod 777 /bin/eclipsebuild
- Choose Project -> Properties -> Builders. Un-tag all existing builders. Click "new" -> Program -> (name it "Builder for KDE"). -> Location: /bin/eclipsebuild -> Working directory /home/user/workspace/myproject1/kdepim.
- Now you can build your project. Every time you restart eclipse, choose myproject1 -> Project -> Properties -> C/C++ Build -> Ok -> Project -> Build.
Revert what eclipse did
To revert what eclipse did to your project simply run
rm -rf .externalToolBuilders/ .project .cproject
Why Subversion does not work
When using Eclipse's svn plugin and building a KDE program, you will get error messages complaining that your svn binary is too old. If you want to try and change this, here is how you get to that error:
- Install the Subversion plug-ins
- Help -> Software Updates -> Available Software -> Add Site -> http://download.eclipse.org/technology/subversive/0.7/update-site/ -> Add Site -> http://www.polarion.org/projects/subversive/download/eclipse/2.0/update-site/
- Now add it: Subversive Site -> Subversive SVN Team Provider Plugin
- Subversive SVN Connectors Site -> Subversive SVN Connectors -> SVNKit 1.3.0 Implementation (Optional)
- Choose File -> New -> Other -> SVN -> Project from SVN -> https://svn.kde.org/home/kde/trunk/KDE/kdepim -> Check out as project configured using the New Project Wizard -> C++ Project -> Makefile Project -> Empty Project. As name, we choose kdepim5 -> Finish
- Set cmake as build environment
- Choose Project -> Properties -> C/C++ Build -> Builder Settings. Un-tag "use default build command", set "cmake" instead. Choose Project -> Properties -> C/C++ Build -> Behavior. Replace "all" by ".".
KDE4's ktimetracker loaded as QtCreator project
Main article: Development/Tutorials/Using_Qt_Creator
This describes how to use QtCreator to develop KDE 4 applications. It has been tested with QtCreator 1.2.80 and SUSE Linux 11.1 but should work same or similar with every combination. As an example KDE application we use ktimetracker from the kdepim module, other applications should work likewise.
Load an existing project
As discussed here we use ktimetracker as example project.
- Import the CMakeLists.txt file
File -> Open -> kdepim/CMakeLists.txt.
- Configure QtCreator to build only ktimetracker
Projects -> ktimetracker -> build settings -> Add a configuration ktimetracker.
As build directory choose kdepim. As arguments for CMake use e.g.
. -DCMAKE_INSTALL_PREFIX=/usr/local -DLIB_SUFFIX=64 -DCMAKE_BUILD_TYPE=debugfull
Start a KDE project
To start a new project you need to tell QtCreator to use the KDE libraries when building. So, choose File -> New... and create your project. We will call it yourproject here. To be able to use KDE's libraries, go to your home directory, change into yourproject and modify the file yourproject.pro. Add the line
Using KDevelop 4 to develop KDE projects is pretty straightforward. You can refer to the KDevelop manual (see http://userbase.kde.org/KDevelop4/Manual) for help on how to use KDevelop in general. This section just covers a few things which are nice for KDE applications in particular.
Fetch source code from git
The Project -> Fetch project... menu allows you to easily clone a KDE project repository, by just selecting "KDE" and typing the project name.
Import a repository you already cloned into KDevelop
To do this, just go to Project -> Open/Import project, and select the top-level CMakeLists.txt file from the repository you want to work on.
|When you work on libraries, you first need to install them before you can test or debug your changes.
Since this is cumbersome and time consuming, you should create symlinks (ln -s) pointing from the build directory to the installation directory for all affected libraries.
Often, even simple programs use libraries internally, for example the settings dialog of Konsole is really a library.
This page was last modified on 23 June 2013, at 15:01. This page has been accessed 17,296 times. Content is available under Creative Commons License SA 3.0 as well as the GNU Free Documentation License 1.2.