Compiling C in KDE

James Gray james at
Mon Jul 10 21:41:05 UTC 2006

Hash: SHA1

Dotan Cohen wrote:
> Is there no C IDE in KDE that allows one to quickly write up a "Hello,
> World!" program, and then compile and run it?
> I'm learning C at the university, and there we have a choice of IDE's.
> My favorite is Bloodshed's dev-cpp, but they all have the same
> feature: You type in something like:
> # include <stdio.h>
> int main () {
>    printf("\nHellow, world!\n");
>    return 0;
> }
> And then the user can hit F9 (or shift-F9, or CTRL-F9, depending on
> program), and the IDE compiles and runs the code in a window. I'm
> looking for something similar for KDE, I've tried Kdevelop, Eclipe,
> and Ajunta. Please tell me that I'm missing something, and that this
> is not as difficult as it seems!

Somewhere between Kdevelop 1.x and the current version they switched
from using simple "gmake" Makefiles to the full qmake stuff.  This
confuses the hell out of newbies (like yourself) but us really good if
you're collaborating on a large project.

Here's the good news:  you can still use standard "gmake" makefiles if
you want, but you'll be compiling on the command line until you learn
the internals of a Kdev project file.

Here's a VERY simple Makefile I used for most of the basic programming
tasks I did at Uni:


$(PROG):        $(PROG).o
                $(CC)  -o $(PROG) $(PROG).o

$(PROG).o:      $(PROG).cpp
                $(CC)  -c $(PROG).c

                rm -f $(PROG) *.o

all:            $(PROG)

proper:         clean $(PROG)

ALWAYS use tabs in makefiles!  So it's:

Save it as "Makefile" in the same directory as your source code.  Now
edit the "PROG=mycprog" line and replace "mycprog" with the file name of
your ".c" file for the assignment without the ".c".  Make sense?

Now, whenever you edit your file in Kdev, you simply save it, open a
command prompt, change to the same directory your assignment is in (Kdev
can do this right in the IDE) and type "make" and hit enter.  Voila!!
You now have an executable called "mycprog" in the same directory as the

This is a small amount of work for a lot of gains.  If you add a header
file, "mycprog.h" simply add it to the "$(PROG).o:" as a dependant like

$(PROG).o:      $(PROG).cpp $(PROG).h

Now, whenever you edit (and save) the "mycprog.h" file, make will see
the change and recompile the object file and relink the executable for
you :)  Simple huh?

Makefiles can save you a LOT of time and the one above is a simple
template that only requires you to change one line to run it against a
different C project.

Googling "gmake" and "Makefile syntax" should help even further :)

> I've another day to turn in my C homework. I've either got to get this
> working in the next hour or so, or I've got to go to the university
> and punch out this assignment on a windows machine. And I'd rather do
> it at home, on Kubuntu, thank you!

Ok - so my help will probably come too late, but maybe for the next
assignment huh?

Good luck!

- -- James
Version: GnuPG v1.4.3 (Darwin)
Comment: Using GnuPG with Mozilla -


More information about the kubuntu-users mailing list