你好,游客 登录 注册 搜索
背景:
阅读新闻

Ubuntu 12.04下安装GTK 2.24.10

[日期:2012-12-28] 来源:Linux社区  作者:XSL1990 [字体:大 中 小]

测试程序

代码如下:

//Helloworld.c
#include <gtk/gtk.h>

int main(int argc,char *argv[])
{
    GtkWidget    *window;
    GtkWidget    *label;
   
    gtk_init(&argc,&argv);
   
    /* create the main, top level, window */
    window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
   
    /* give it the title */
    gtk_window_set_title(GTK_WINDOW(window),"Hello World");
   
    /* connect the destroy signal of the window to gtk_main_quit
    * when the window is about to be destroyed we get a notification and
    * stop the main GTK+ loop
    */
    g_signal_connect(window,"destroy",G_CALLBACK(gtk_main_quit),NULL);
   
    /* create the "Hello, World" label */
    label = gtk_label_new("Hello, World");
   
    /* and insert it into the main window */
    gtk_container_add(GTK_CONTAINER(window),label);
   
    /* make sure that everything, window and label, are visible */
    gtk_widget_show_all(window);
   
    /* start the main loop, and let it rest until the application is closed */
    gtk_main();
   
    return 0;
}

编译运行

1、编译

gcc -o Helloworld Helloworld.c `pkg-config --cflags --libs gtk+-2.0`

2、运行

./Helloworld

上图

linux
相关资讯       GTK安装  GTK 2.24.10 
本文评论   查看全部评论 (0)
表情: 表情 姓名: 字数

       

评论声明
  • 尊重网上道德,遵守中华人民共和国的各项有关法律法规
  • 承担一切因您的行为而直接或间接导致的民事或刑事法律责任
  • 本站管理人员有权保留或删除其管辖留言中的任意内容
  • 本站有权在网站内转载或引用您的评论
  • 参与本评论即表明您已经阅读并接受上述条款