Results 1 to 3 of 3

Thread: Can anyone please tell me how to compile a gtk program ?

  1. #1
    Join Date
    Apr 2012
    Location
    广州
    Beans
    231
    Distro
    Ubuntu Gnome 16.04 Xenial Xerus

    Cool Can anyone please tell me how to compile a gtk program ?

    I have made a program that uses gtk for GUI interface
    It can be successfully compiled in codeblocks before when I was using Ubuntu 11.10. But when I upgrade to 12.04, I have to re-install the gtk dev package. And when I compile the program, it says some headers can't be found, For example, gtkconfig.h, cairo.h.

    I have found that some of those lost headers are in another directory that codeblocks doesn't include those when I created the project with default settings for gtk program. I want to change the search directories but it says that I can "use project options only". How can change it, or is there any other solution ?

    Thank you ^_^
    Attached Images Attached Images

  2. #2
    Join Date
    May 2007
    Location
    Leeds, UK
    Beans
    1,675
    Distro
    Ubuntu

    Re: Can anyone please tell me how to compile a gtk program ?

    Are you able to compile a GTK+ program from the command line?

    hello.c
    Code:
    #include <gtk/gtk.h>
    
    int main( int argc, char **argv)
    {
    	GtkWidget *window;
    
    	gtk_init(&argc, &argv);
    
    	window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
    	gtk_widget_show(window);
    
    	gtk_main();
    
    	return 0;
    }
    Then, to compile:

    Code:
    gcc -o hello hello.c `pkg-config --libs --cflags gtk+-2.0`
    If it doesn't work, the packages you need for GTK2 are:

    Code:
    sudo apt-get install build-essential libgtk2.0-dev
    Obviously if you are working with GTK3, things are slightly different.

    If all that works, you can concentrate on the setup of the IDE, or other packages.
    Last edited by r-senior; April 10th, 2012 at 09:49 AM.

  3. #3
    Join Date
    Apr 2012
    Location
    广州
    Beans
    231
    Distro
    Ubuntu Gnome 16.04 Xenial Xerus

    Smile Re: Can anyone please tell me how to compile a gtk program ?

    Thank you

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •