Ubuntu 下安装GTK

环境:Ubuntu kylin 14.04

1. 安装
sudo apt-get install build-essential
sudo apt-get install gnome-core-devel 
sudo apt-get install pkg-config
sudo apt-get install devhelp
sudo apt-get install libglib2.0-doc libgtk2.0-doc
sudo apt-get install glade libglade2-dev
sudo apt-get install libgtk2.0-dev

2.测试

//Helloworld.c

#include 

int main(int argc,char *argv[])
{
    GtkWidget    *window;

    gtk_init(&argc,&argv);
 
    window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
    gtk_window_set_title(GTK_WINDOW(window),"Hello World");
    gtk_widget_show_all(window);
    gtk_main();
    
    return 0;
} 

3.编译

gcc -o Helloworld Helloworld.c `pkg-config --cflags --libs gtk+-2.0`
[注意] `是数字1左边的那个兼,不是单引号


4.运行

./Helloworld

5.结果


你可能感兴趣的:(Ubuntu)