The best way to start learning a programming language is by writing a program.
How to edit and compile the program?
That depends on the compiler you are using.
First of all, you should write a simple program using C language.
This is a simple program:
int main( int argc,
char *argv )
gtk_init (&argc, &argv);
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
Now about the compilers:
gcc is the “GNU” C Compiler
g++ is the “GNU C++ compiler
cc is the “Sun” C Compiler
CC is the “Sun” C++ compiler
I will use gcc because is a C program.
When it contains Xlib graphics routines the command is :
gcc myprogram.c -o myprogram -lX11
( see -l = link and X11 is Xlib).
What is pkg-config?
This is a helper tool.
It helps you insert the correct compiler options on the command line.
Your application can use something like this :
gcc -o test test.c `pkg-config --libs --cflags glib-2.0`
How did it work?
When a library is installed a .pc file should be included.
This file tells us that libraries can be found in
/usr/local/lib and headers in
But first of all, you must install the libs.
On my example I need this gtk2-devel.i686, so I use :
yum search gtk2-devel
Loaded plugins: presto, refresh-packagekit
============= Matched: gtk2-devel =================
gtk2-devel.i686 : Development files for GTK+
And I compile with this:
$gcc `pkg-config --cflags --libs gtk+-2.0` -o app app.c
And the result is: