GUI programming with GTk+

it was a long time ago that i had tried a simple hello world program from 'Beggining' Linux programming and failed badly , going by the difficulty i had in figuring out the flags to be given to gcc and and the directories and libs i had to explicitly include, but i hvae atlast found some success, well it is not a achievement as all i did was follow the same book and do what it said , but i feel relieved , it has been my dream to develop a GUI based software for managing 'small business' . Which can be easily configured and used for any sort of 'small ' range business, as all of them have the same basic backdrop. So finally i have started working with GtkObjects and GtkWidgets, so it should not be long before i am grinding out some really good stuff !!!
Everytime we compile a program using the Gtk+ packages, we have to include some metadata about the include directories containing the headers, the directories to find the libraries in and all such stuff, it is quite difficult to figure these out individually, and that was the problem i faced initially. The book gives a solution , it uses the command 'pkg-config -cflags -libs gtk+-2.0' to give the details of the cflags and the libraries ! So for compiling a program named 'helloworld.c' i would give the following command according to the book, :
# gcc helloworld.c -o helloworld `pkg-config -cflags -libs gtk+-2.0`
note the reverse quotes they substitute the ouput of pkg-config command , but THAT DOES NOT WORK, the man page for pkg-config shows that the options to be given to it are ' --cflags --libs' , i am not sure whether this has changed since the time the book was written , but what is given in the book doesn't work with me , so the correct thing would now be :
# gcc helloworld.c -o helloworld `pkg-config --cflags --libs gtk+-2.0`
that compiles and gives the output !!
pkg-config is a utility for displaying the meta-data for packages which are installed on the system , check out the man pages for more detailed info !!

Comments

Dipen Chaudhary said…
hmmm interesting blog, hmmmm how about doing this business application with LUG ?
also check ur e mail and LUG site ..
uma said…
good observation, I think thats a print mistake, its a customary to append '--' to the options or '-' to the options short letter.
I mean either '--install' or '-i'.

In addition, if you are using pkg-config utility, the package should reside in the exported PKG_CONFIG_PATH directory. Usually it would reside in wither '/usr/lib/pkgconfig' or '/usr/local/lib/pkgconfig' as 'packagename.pc'

The package name provided to the pkg-config utility is before the suffix '.pc'.


Alternatively u could achieve the same using: '-I' and 'l' options.
Satish said…
well, ya when i got hooked up with pkg-config i tried to figure out how it works, and eventually from some trials and the man pages found out what u have mentioned, though i should mention , it is a very interesting utiltiy , and i have one small doubt , is it a general utility or a package specific, like is pkg-config provided only with gnome , and only with QT or something like that ???
uma said…
@satish,
Its a general utility. I didnt get what u mean by package specific. If u mean to say ,whether it is a desktop specific, then its no, its from freedesktop.org, so the utility can be used by any desktop.

The common usage is while compiling, to help the auto-tools like automake, autoconf, irrespective of the gnome or kde desktops.
Satish said…
ya i got it , yea actually my question was whether it was specific to a software , but ya a litlle googling tells that it is not , .....
thanks

Popular posts from this blog

Was history ! :)

beginning again

Kernel installer !