Install GTK in Ubuntu
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的更多相关文章
- Install Docker on Ubuntu
Install Docker on Ubuntu Estimated reading time: 17 minutes Docker is supported on these Ubuntu oper ...
- (转) How to install eclipse in ubuntu 12.04
源地址:http://www.krizna.com/ubuntu/install-eclipse-in-ubuntu-12-04/ Eclipse installation in ubuntu 12. ...
- Install OpenCV on Ubuntu or Debian
http://milq.github.io/install-OpenCV-ubuntu-debian/转注:就用第一个方法吧,第二个方法的那个sh文件执行失败,因为我价格kurento.org的源,在 ...
- Install OpenCV-Python in Ubuntu
之前安装python版opencv,需要下载whl文件,进行安装,这是在window环境下的: 安装opencv_python,下载whl包 安装系统python下的opencv 今天发现一个简单的方 ...
- 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 ...
- 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 ...
- How to Install PhantomJS on Ubuntu 16.04
Introduction PhantomJS is a scripted, headless browser that can be used for automating web page inte ...
- install cinnamon on ubuntu 14.04
emotion: I feel not comfortable with ubuntu 14.04 default desktop unity,i still look for a alternati ...
- 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 ...
随机推荐
- android界面优化笔记(TODO)
1.避免使用线性布局的层层嵌套,要使用相对而已.使用线性布局越多,嵌套越多 官方文档: Optimizing Your UI
- DS18B20 for STM32 源代码 【worldsing笔记】
DS18B20是DALLAS公司生产的一线式数字温度传感器,具有3引脚TO-92小体积封装形式:温度测量范围为-55℃-+125℃,可编程为9位-12位A/D转换精度,测温分辨率可达0.0625℃.主 ...
- 谷歌下设置滚动条的css样式
.oLi-lists-scroll::-webkit-scrollbar { width:5px; padding:1px; background:url(../images/repeat-bar. ...
- 为什么只有在用Visual Studio启动程序时会抛出InvalidOperationException异常
博客搬到了fresky.github.io - Dawei XU,请各位看官挪步.最新的一篇是:为什么只有在用Visual Studio启动程序时会抛出InvalidOperationExceptio ...
- web工作方式,浏览网页,打开浏览器,输入网址按下回车键,然后会显示出内容,这个过程是怎样的呢?
以下内容摘自<Go Web编程>,介绍的通俗易懂. 我们平时浏览网页的时候,会打开浏览器,输入网址后按下回车键,然后就会显示出你想要浏览的内容.在这个看似简单的用户行为背后,到底隐藏了些什 ...
- 微信公众平台java开发详解(工程代码+解析)
原文:http://blog.csdn.net/pamchen/article/details/38718947 说明:本次的教程主要是对微信公众平台开发者模式的讲解,网络上很多类似文章,但很多都让初 ...
- 给定表达式[x/2] + y + x * y, 其中x,y都是正整数。
改进了一下,不过还是要十多秒吧. package com.boco.study; import java.math.BigDecimal; import java.util.Calendar; imp ...
- android121 zhihuibeijing SlidingMenu(侧边栏效果,使用开源库)
## Splash ## - 旋转 RotateAnimation - 缩放 ScaleAnimation - 渐变 AlphaAnimation 工程可以作为一个库被其他工程当成一个Library使 ...
- 进程环境之C程序的存储空间布局
从历史上讲,C程序一直由下面几部分组成: 正文段.这是由CPU执行的机器指令部分.通常,正文段是可共享的,所以即使是频繁执行的程序(如文本编辑器.C编译器和shell等)在存储器中也只需有一个副本,另 ...
- PAT 1005
1005. Spell It Right (20) Given a non-negative integer N, your task is to compute the sum of all the ...