Linux , C and GTK

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:

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 :

( 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 :

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 /usr/local/include.
But first of all, you must install the libs.
On my example I need this gtk2-devel.i686, so I use :

And I compile with this:

And the result is:
gtk tutorial

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.