Developing C/C++ Applications with the KDevelop IDE

A sample implementation to help you get familiar with KDE's IDE and Qt Designer.

The aim of this article is to enable you
to create an application with the KDevelop Integrated Development
Environment (IDE) on a Linux/UNIX system running KDE 2. We explain
this process by creating a sample application that gives some
insight into the development framework and how it works. This might
require getting your development environment set up correctly, so
that you can work efficiently when getting started with your very
own application or extension for the KDE 2 Desktop.

What Is an IDE?

An IDE provides the user with a complete set of tools that
integrate into one graphical environment. It's an enormous bonus
for developers if the environment remains flexible enough to handle
things separately or outside of the IDE, so they are not forced to
use the IDE's features where they think other tools are more
appropriate.

Although IDEs on other platforms, especially on Microsoft
operating systems, come with all the tools bundled into one
package, it's very different on a UNIX system. With UNIX, the
compiler, which is needed to create applications from the
programming code that can be run on a machine, is part of the
operating system. Various tools that can be used in conjunction
with the compiler, like make or the GNU tools, are delivered as
separate packages, and an IDE makes use of these tools
internally.

The KDE Project, comes with an IDE called KDevelop. This IDE
can be used on any UNIX system to develop software, especially KDE
software, but not limited to it. Many experienced UNIX programmers
use it for plain C and C++ programming.

Setting Up Your Development Environment

If you're using a popular Linux distribution, you should
encounter few problems when setting up the IDE; especially when it
already ships with KDevelop and takes over the installation of all
the tools needed. What you need, in any case, is a C/C++ compiler,
such as the current version of gcc that ships with current
distros.

The next task is installing the GNU tools autoconf and
automake and the package-building utility make.

For finding program errors, you need to install a debugger
installed, which is called gdb, the GNU debugger. To complete your
environment, the version control management utility, CVS, can be
helpful, as well as source code documentation software, such as
kdoc and doxygen.

The last package you need is KDevelop itself; it can be
downloaded from the KDE web site at
www.kde.org or from your
distribution's web site.

If these requirements are all met, you still might be missing
at least one very important part of your development environment,
especially for KDE programming: the header files of the libraries
that you intend to use. These files contain the API (application
programming interface) that the compiler needs to have in order to
look up which functionality you want to use while compiling your
application.

The header files (also known as include files) should be
located in your $KDEDIR/include (KDE header files) and your
$QTDIR/include (Qt header files) directories. Make sure you have
these installed; usually they're in packages with names such as
kde-devel and qt-devel.

Further, there is the Qt Designer, a graphical user interface
builder that is easy to use and works together with KDevelop to
create KDE/Qt applications, so make sure that you have it installed
as well.

Note: the KDEDIR and QTDIR environment variables should point
to the directories where your KDE 2 and Qt 2.x installations are
located, e.g., in your ~/.bashrc: export KDEDIR=/opt/kde2; export
QTDIR=/usr/lib/qt-2.3.0.

Make Yourself Comfortable

As a programming beginner, it is crucial to have a successful
experience. Let's start with creating your first KDE application.
Open up KDevelop and make yourself comfortable with the
environment.

In the treeview on the left side, you should see some books
that you can unfold and that contain documentation included with
KDevelop--almost 500 pages that can help you in almost every
development situation. The second folder in that tree contains
books with the API documentation of the Qt and KDE
libraries.

In case you don't see them, set the appropriate paths in
KDevelop through Options-->KDevelop Setup in the Documentation
section. The other windows in the treeview will be used during
development, and we will refer to them later. The right-hand window
contains three tabs: two editor windows and a browser window, which
will display the HTML documentation you select on the left treeview
(see Figure 1).

Figure 1. Welcome to the Desktop

The window on the bottom will be used to inform you about
what your environment is currently doing; it will show the compiler
output later on and display any error messages.

Hello all,
i would like to know, is there any options to configure debugger for Kdevelop. presently i am working on QT based project so i would like to debug the errors but some how i cannot. it simply does nothing if i use debug which is present in the Kdevelop IDE. i dont know how to configure it. i need it to be like a visual C++ debugger so that i can debug my code line by line. please provide appropriate information on this. Thanks

Kdevelop is great but it is very complex for beginners and people that doesn't develop KDE applications. I prefer to use Anjuta (http://anjuta.sourceforge.net) because it is more general and the syntax highlight is better than Kdevelop.

Different from KDevelop which finishes all the tasks under linux, Magic C++ is a kind of visual remote unix and linux C/C++ IDE under windows.You can have a look at http://www.magicunix.com . It looks just like Visual C++ and supprots for editing, compiling, debugging etc.

I did not installed c-cpp-reference and kdevelop-doc. Now I've it but Kdevelop still fails on setup. It says that "The documentation of the kde-library could not be found. It will be automatically generated in the next step". But then it ask me for the path of kdelibs and I can found them; it claims for the sources, that probably I've not installed but as I have now kdevelop-doc I think I'll no more need that sources... Could it be I can solve this later without installing that sources.

On the other hand, when I'm indexing the documentation (Qt only, as Kdevelop docs. are not found), it says that an 'htdig.conf' not were found... but I've htdig installed and an /etc/htdig/htdig.conf... I've tried linking that file from /etc/htdig.conf but it doesn't work... any ideas?

An IDE would be really nice if for nothing else than having a fast way to view classes in a program and bounce around between them, but without VIM as the editing component, it's too painful to bother with.

Ralf, you're a KDevelop developer, have a KDE.org email address, and you claim thet 1.4 w/2.1.1 is the latest release of KDevelop??? I'm running debian/sid, with 2.2.2, and my KDevelop claims that it is 2.0.2. Anyways, good article, even it it looks like it should be dated March 6th, 2001 :-)

I am currently using VisualFoxPro 6.0 to develop inhouse applications at work. With the arrival of Qt 3 and its data-aware apps KDevelop / QtDesigner has reached the critical level of power that puts it in direct competition with VFP6+, VB, PB, etc... for ease of development and productivity.

As a test, I used QtDesigner to write an addressbook app that connected to my PostgreSQL database Addresses table. What was neat was that I didn't have to write a single line of code for it to work in the preview mode. I can easily flip back and forth between the dev mode and the preview mode, just as I do in VFP. Oh, the connection to the PostgreSQL database was handled by the supplied QPSQL7 driver.

Well, my comment made a lot more sense when this was originally posted, and Ralf had a comment about how the latest KDevelop was 1.4 that comes with 2.1.1. Now it appears to have been edited, and I'll admit I look like an ass :-) You'll note, however, that I didn't claim to be running the latest KDevelop, just that the version I *am* running was higher than what he *claimed* was the highest number. As it was obviously a typo of some sort (actually, I suspect at least a couple of the paragraphs were cut and paste from another source) my response was simply a slightly-humourous way of telling Ralf such. As for it appearing to have been written by a child, I mispelt one word. I assure you, many people who are not small children do that ;-)

P.S. *NO* I'm not saying Ralf is guilty of plagarism, just that he has undoutably written about KDevelop before, and simply lifted the introduction, rather than rewritting it. A very smart thing to do, unless you forget to proof-read it B)

Trending Topics

Upcoming Webinar

Getting Started with DevOps - Including New Data on IT Performance from Puppet Labs 2015 State of DevOps Report

August 27, 2015
12:00 PM CDT

DevOps represents a profound change from the way most IT departments have traditionally worked: from siloed teams and high-anxiety releases to everyone collaborating on uneventful and more frequent releases of higher-quality code. It doesn't matter how large or small an organization is, or even whether it's historically slow moving or risk averse — there are ways to adopt DevOps sanely, and get measurable results in just weeks.