reference: http://www.cnblogs.com/niocai/archive/2011/07/15/2107472.html

一、安装

  1、安装gcc/g++/gdb/make 等基本编程工具

$sudo apt-get install build-essential

  2、安装 libgtk2.0-dev libglib2.0-dev 等开发相关的库文件

$sudo apt-get install gnome-core-devel 

  3、用于在编译GTK程序时自动找出头文件及库文件位置  

$sudo apt-get install pkg-config

  4、安装 devhelp GTK文档查看程序

$sudo apt-get install devhelp

  5、安装 gtk/glib 的API参考手册及其它帮助文档

$sudo apt-get install libglib2.0-doc libgtk2.0-doc

  6、安装基于GTK的界面GTK是开发Gnome窗口的c/c++语言图形库

$sudo apt-get install glade libglade2-dev
或者
$sudo apt-get install glade-gnome glade-common glade-doc

  7、安装gtk2.0 或者 将gtk+2.0所需的所有文件统通下载安装完毕

$sudo apt-get install libgtk2.0-dev
或者
$sudo apt-get install libgtk2.0*

  

二、查看GTK库版本

  1、查看1.2.x版本

$pkg-config --modversion gtk+

  2、查看 2.x 版本

$pkg-config --modversion gtk+-2.0

  3、查看pkg-config的版本

$pkg-config --version

  4、查看是否安装了gtk

$pkg-config --list-all grep gtk

  

三、测试程序

//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(); return0;
}

  

四、编译运行

  1、编译

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

  2、运行

$./Helloworld

Install GTK in Ubuntu的更多相关文章

  1. Install Docker on Ubuntu

    Install Docker on Ubuntu Estimated reading time: 17 minutes Docker is supported on these Ubuntu oper ...

  2. (转) How to install eclipse in ubuntu 12.04

    源地址:http://www.krizna.com/ubuntu/install-eclipse-in-ubuntu-12-04/ Eclipse installation in ubuntu 12. ...

  3. Install OpenCV on Ubuntu or Debian

    http://milq.github.io/install-OpenCV-ubuntu-debian/转注:就用第一个方法吧,第二个方法的那个sh文件执行失败,因为我价格kurento.org的源,在 ...

  4. Install OpenCV-Python in Ubuntu

    之前安装python版opencv,需要下载whl文件,进行安装,这是在window环境下的: 安装opencv_python,下载whl包 安装系统python下的opencv 今天发现一个简单的方 ...

  5. How To Install Cacti On Ubuntu 14

    How To Install Cacti On Ubuntu 14.04/14.10 by anismaj Cacti is an open source web based network moni ...

  6. How To Install Nginx on Ubuntu 16.04 zz

    Introduction Nginx is one of the most popular web servers in the world and is responsible for hostin ...

  7. How to Install PhantomJS on Ubuntu 16.04

    Introduction PhantomJS is a scripted, headless browser that can be used for automating web page inte ...

  8. install cinnamon on ubuntu 14.04

    emotion: I feel not comfortable with ubuntu 14.04 default desktop unity,i still look for a alternati ...

  9. ubuntu 16.04上源码编译和安装cgal并编写CMakeLists.txt | compile and install cgal on ubuntu 16.04

    本文首发于个人博客https://kezunlin.me/post/39ab7ed9/,欢迎阅读最新内容! compile and install cgal on ubuntu 16.04 Guide ...

随机推荐

  1. poll()

    # include < sys/ poll. h> int poll ( struct pollfd * fds, unsigned int nfds, int timeout) ; 和s ...

  2. [OC Foundation框架 - 5] NSString的常用方法

             NSString *s1 = ";   1.比较 使用 == 号比较的是字符串地址 NSString *s4 = @"abcdefg"; NSStrin ...

  3. jquery完成带单选按钮的表格行高亮显示

    jquery完成带单选按钮的表格行高亮显示 上篇博客写的是复选框的,这次写的是单选框的,有时查询的时候,只能选择一条记录,如果将选中的这条记录的行高亮显示,同时该行的单选按钮也被选中了,这样会提高用户 ...

  4. UIViewController生命周期测试

    push进入  -[NaviRootVC viewWillDisappear:]  -[NextVC viewWillAppear:]  -[NextVC viewWillLayoutSubviews ...

  5. HBase in 2013

    2013年马上就要过去了,总结下这一年HBase在这么一年中发生的主要变化.影响最大的事件就是HBase 0.96的发布,代码结构已经按照模块化release了,而且提供了许多大家迫切需求的特点.这些 ...

  6. 2014 ACM/ICPC 鞍山赛区现场赛 D&amp;I 解题报告

    鞍山现场赛结束了呢-- 我们出的是D+E+I三道题-- 吾辈AC掉的是D和I两道,趁着还记得.先在这里写一写我写的两道水题D&I的解题报告吧^_^. D题的意思呢是说星云内有一堆排成一条直线的 ...

  7. C#实现在Winform中嵌入Word和Excel

    http://www.cnblogs.com/wuzi145/archive/2012/05/08/2490680.html 在此只是介绍一个简单控件:dsoframer.ocx的使用,这个控件需要通 ...

  8. iOS开发——UI篇OC篇&UITableView多项选择

    UITableView多项选择 自定义cell和取到相应的cell就行了 TableViewCell.h #import <UIKit/UIKit.h> @interface TableV ...

  9. 几种sap增强的查找方法

    ***方法一**************************************** 通过SE30,运行TCODE后,点Evaluate后,查看运行时间分析评估:命中清单. 找以“exit”开 ...

  10. java_可变参数构造器 Bulder模式

    package com.test1.www; class NutritionFacts { //必须 private int servingSize; private int servings; // ...