How to create a GUI(Graphical User Interface) using C programming Language..

How to create a GUI(Graphical User Interface) using C programming Language???  That was a big problem to me when I’m in the University first year. I knew Java GUI Designing, but couldn’t find way to do it in C language. I spent many time to learn that. I think now it’s time to share those knowledge :D . But since there are lot to discuss on that topic, I’m going to spelt the whole tutorial into several posts.  In this post I’ll discuss how to set up the development environment.

Setting up the development environment for C language GUI designing.

Ok let’s begin. First we need to have several tools for that.

1) Code Blocks IDE

2) Glade IDE

3) Gtk+

4) Libglade library

So install those things on your computer. I’ll give a hint to get it much easier. If you are Ubuntu user, go to Ubuntu software center or Synaptic package manager. Find code blocks and install. Then Find for Glade and before install, check all the Add-ons then install. In this way it will automatically install gtk+ and libglade. So you don’t want to worry about that:D.

A screen shot of Code Blocks IDE..

Now you have to configure Compiler and Debugger settings in Codeblocks IDE.

  • Open Code Blocks–> goto Compiler and Debugger settings

  • Select Other options in Compiler settings tab and paste this.

            `pkg-config –cflags gtk+-2.0 gmodule-export-2.0`
            `pkg-config –cflags libglade-2.0`

  • Then select Other linker options in Linker settings tab and paste this.

           `pkg-config –libs gtk+-2.0 gmodule-export-2.0`
           `pkg-config –libs libglade-2.0`

A screen shot of Glade Interface designer…


But you always free to compile your program on the terminal too. If you wish to do so it should be like this.

gcc `pkg-config –cflags libglade-2.0 –libs gtk+-2.0“pkg-config –libs gtk+-2.0 gmodule-export-2.0` main.c

Ok thats all for now . In next post I’ll explain how to Design a GUI using Glade Interface Designer :D .

 

Thank you

Gihan Malan De Silva @ gihansblog.com

13 thoughts on “How to create a GUI(Graphical User Interface) using C programming Language..

  1. Hey, your review above surely got me interested up to the very last word, so I just had to comment on it. Luckily I noticed it over Google and I must confess to you I rarely read the entire article of a blog as I more or less always get bored of the “gibberish” which is offered to me on a almost daily basis. In contrast your article got me hooked from the tag-line to the very end. Really unique these days in the blogging world (if you ask me). Consequently: thanks a lot and please please go on with your good work. I’ll surely come back and look for new stories! Happy Blogging

  2. Hey, I am using windows 7,
    i’ve installed codeblocks, glade IDE+gtk,
    and did what you’ve ask to do in codeblocks.
    but how can i install libglade library??
    please help.

  3. does the same thing as a GUI site install: that is, it only installs local install profiles and does not update. The reason is presumably installation profiles are designed and tested around specific versions of modules.

Leave a Reply