views:

960

answers:

8

I recently set up, for a learning exercise, an Ubuntu desktop PC with KDE 4.2, installed Eclipse and started to look for information on how to develop for KDE. I know there's KDevelop and will probably have a look at that at some time in the future. Right now, however, I don't have the correct headers and libraries for creating KDE applications in C/C++ using Eclipse. If I have the following:

#include <kapplication.h>

it fails to compile since there are dependancies on other header files that are not present on my hard disk or reference classes that aren't declared anywhere.

So, the question is, what packages do I need to install in order to have the correct set of headers to allow me to write applications for KDE 4.2? Are there any packages I shouldn't have? Alternatively, if there are no packages then where can I get the appropriate files?

As a corollary, are there any good tutorials on KDE development, something like the Petzold Windows book?

EDIT: Clarifying what I'm really after: where can I download the correct set of header files / libraries in order to build a KDE application? IDEs to compile code aren't a real problem and are easy to get, as is setting up compiler options for include search paths and so on. Does the KDevelop package have all the correct include and library files or are they separate? I guess they are separate as KDevelop is an IDE that can do other languages as well, but I'm probably wrong. So, the KDE/Qt header files I have don't work, where do I get the right ones?

Skizz

+2  A: 
VonC
Yeah, I'd read some of that. I was hoping to use Eclipse natively, i.e. not use CMake. There is a big 'sudo aptitude install' command line on one of pages. I'll give it go and see what happens.
Skizz
That is a lead indeed, but I was not suggesting for you to use CMake, just import what you need. However you may define a custom build using CMake: I will update my answer
VonC
Nope you cannot easily plug an external script as your custom builder in PDT... Only define it as an "external tool" and that is not very convenient, except it would allow you to keep the same window at all time.
VonC
+1  A: 

If Eclipse doesn't provide you with some wizard/initial project setup for a KDE program, I would recommend you to install kdevelop and start such a project there (just write a little Hello World). Then you can look at the files created and follow the build process to get a better understanding and possibly migrate them to Eclipse.

Even if you strip off compiler flags for the right include directories, etc. and it works-you should think about using one of the common, established ways to build your software (like qmake for QT, cmake? for KDE,..). If you start using these right now, deploying/distribution your software will be a breeze.

ypnos
+3  A: 

make sure you have installed build-essential package. For more documentation available from the command line, install glibc-doc, manpages-dev, gcc-*-doc, libstdc++*-doc (replace '*' with suitable version numbers for your system)

EDIT: I'm going to accept this one, but with a few extra bits.

Firstly, this page had a pair of 'sudo aptitude install' which I commands which I used to get some required packages. I also got the KDevelop and QDevelop applications although I'm not sure they are required. There was also another package I needed: 'kdelibs5-dev' and this one appears to be the key package. Everything eventually worked after getting that one. Eclipse and KDevelop were both happy building a simple application once the compiler settings were set up - just search paths and library file names for Eclipse.

From first impressions, Eclipse appears better than KDevelop for the single reason that the tool windows in Eclipse can be detached from the main window and float - useful on a dual monitor setup. I couldn't see anyway to do that in KDevelop (I'm sure someone will comment on how to do this).

dmityugov
+1  A: 

check out pkg-config.

For example you can see the libraries installed by tiping:

pkg-config --list-all

For example to find the compilation flags of the gdk library:

~$ pkg-config --cflags gdk
-I/usr/include/gtk-1.2 -I/usr/include/glib-1.2 -I/usr/lib/glib/include
~$

Eventually you will link with the library and you will need also libraries:

~$ pkg-config --libs gdk
-lgdk -lXi -lXext -lX11 -lm -lglib  
~$

Note: you will need the development libraries installed in order to be able to do that.

Iulian Şerbănoiu
A: 

Eclipse is far better than Kdevelop, but Eclipse do not have support for developing Kde application. If you want to develop application for KDE, than you should go for Kdevelop. If you are using Qt not kde libraries than use Qt Eclipse QtCreator is another good option for developing Qt applications.

Sharique
A: 

I've been using KDevelop4 for a while now and it's been great. KDevelop3 is heavy and has signs of bitrot (300MB RAM usage with one 50k-line project). I have KDevelop4 (since the beta, I've been running trunk lately) and it takes ~100MB of RAM (same project) and the contextual highlighting, awesome completion, and other goodies make it hard to go back to "boring" old syntax highlighting. I don't know if experimental has any builds of it available, but with how many packages that are out there, I would almost be surprised if nobody has them for Debian. Also, all toolbars can be detached in all KDE4 apps, so KDevelop4 has that as well.

MathStuf
+1  A: 

To get all the dependencies required to build an app on Debian (and presumably Ubuntu), use "apt-get build-dep". So pick a random KDE app -- kasteroids? -- and run:

apt-get build-dep kasteroids

No need to guess what tools and libraries you need to build a KDE app.

Ken
+1  A: 

I can add a useful tip if you notice that you lack a file and want to find out which package that provides it. Install apt-file, then you can run apt-file search filename to find out the package that contains that file. Note that you have to run apt-file update to get the latest information first.

Zitrax