Compiling C in KDE

Dotan Cohen dotancohen at
Mon Jul 10 22:19:46 UTC 2006

On 11/07/06, John L Fjellstad <john-ubuntu at> wrote:
> "Dotan Cohen" <dotancohen at> writes:
> > Is there no C IDE in KDE that allows one to quickly write up a "Hello,
> > World!" program, and then compile and run it?
> unix is an IDE :)
> At worst, you can just do this from the command line:
> gcc file1.c file2.c file3.c
> gcc will create the executable a.out in the current directory.
> It's probably too late now, but I would recommend you learn make and
> compiling from the command line (unix was built to give you all the
> power of an IDE and more).
> Here are some quick notes for next time.
> gcc and g++ are the C and C++ compilers respectivelly.  They pretty much
> take the same arguments.
> So, at its most basic, you can call it like this (where ${CC} is the
> compiler, ${EXECUTABLE} is the name of the executable you want to
> create, and ${OBJECTFILES} are all the object files you want link
> together to create the executable)
> To create objectfiles, type
> ${CC} -c ${SOURCEFILE}
> There are two variables that are used that you might want to know about:
> CFLAGS and CXXFLAGS.  CFLAGS are flags that are used by gcc, and
> CXXFLAGS are used by g++.
> Once you understand that, you can create the Makefile.  Makefiles are
> basically just rules you create so that the make program nows what to do
> next.
> There are two basic rules, variable assignments and targets.
> So, variable assignments, say you want a specific version of gcc, you
> can assign it like this
> CC = gcc-3.3
> Targets are stuff you want done. So,
> (You can have multiple dependencies)
> For instance,
> myexec: myexec.o
>         ${CC} {CFLAGS} -o myexec myexec.o
> This means, myexec (TARGET) depends on myexec, it's created by calling
> ${CC} (whatever that variable is assigned to, by default gcc, if you
> don't assign it), using CFLAGS.  Note that before the ${CC} there is a
> <tab> (very important!).
> You can also have targets that call shell programs. (${CC} is basically a
> shell program).
> For instance, most programs have a clean target:
> clean:
>         rm -f *.o *~ ${EXECUTABLE}
> Putting it all together.  Create a Makefile that looks like this:
> ##########
> CFLAGS = -Wall
> myexec: myexec.o main.o
>         ${CC} ${CFLAGS} -o myexec myexec.o main.o
> myexec.o: myexec.c
>         ${CC} ${CFLAGS} -c myexec.c
> main.o: main.c
>         ${CC} ${CFLAGS} -c main.c
> clean:
>        rm -f *.o *~ myexec
> #########
> -Wall is a switch for gcc that gives you warnings if you have done
> something suspect.
> To compile, just type
> make
> and everything will compile for you. It will also only compile stuff
> that get changed between compiles. So you change something in myexec.c,
> but not in main.c, then only myexec.c gets compiled before linking.
> To run any particular rule, give
> the name of the rule, ie
> make clean
> Once you have mastered the basic, you can do some pretty advanced stuff
> (for instance, combine the object creation instead of having separate
> rules for each object). Also, once you have mastered Makefiles, you
> aren't stuck with a particular IDE for a particular language.
> --
> John L. Fjellstad
> web:          Quis custodiet ipsos custodes

John, thank you for the explanation! I should have maybe been clearer
as to my intentions:
I'm studying C in the university. Sometimes I make five hundred small
changes to very simple code and need to run it after each change. This
is where the ability to run within the editor is important. We're not
learning to create GUIs, rather it is an introductory course
(recursive functions, arrays, pointers, etc). I need an editor that I
can compile and run code inside the editor- an IDE in other words.

I think I'm just going to reinstall XP for the remainder of the next
two semesters and use Dev-cpp. I can't believe that for one stupid
program I have to give up on Kubuntu. But I must finish this
assignment by tomorrow and this is getting ridiculous.

Please, if anybody knows of an IDE that runs on linux, let me know!

Dotan Cohen

More information about the kubuntu-users mailing list