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 ...
随机推荐
- 如何把匿名类型.GetType()返回的对象传进泛型里面[转]
//怎么取得匿名类型的Type放到 //泛型T当中?? var 匿名 = new { A = 0, B = 1 }; Type t = 匿名.GetType(); //然后下面 var xx = db ...
- 精彩,sinox.org官网贴满winxp死亡大字报
sinox杀死windowxp不可避免,不用说,微软还自己掐死他!!! 中国人会升级正版 windows7吗?昨天也许会,但今天不会了,因为 sinox大字报出来了! 这下举国皆知了. 换装sinox ...
- SVG 矢量图形格式
SVG(Scalable Vector Graphics)是基于 XML 的一种矢量图形格式,它即可以作为单独的图形文件使用也可以嵌入到网页中并由 JavaScript 来操作,非常方便和灵活.SVG ...
- Ecshop图片不清晰怎么办?
很多人说缩略图的质量不高,模糊,那是因为gd库生成缩略图时,默认生成jpg缩略图或商品图的质量是75.可以通过修改生成缩略图质量的默认值来提高缩略图的质量. 找到includes/cls_image. ...
- Android 百度地图API 定位 导航
看看这个利用百度地图定位并实现目的地导航的Demo. 首先看实现效果: 进 入后首先会得到当前位置,在地图上显示出来.在输入框中输入目的地后,就会在地 ...
- Codeforces Round #319 (Div. 1) C. Points on Plane 分块
C. Points on Plane Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/576/pro ...
- android学习日记24--Android 菜单开发
菜单是任何应用程序必不可少的一项.按下Menu键或者长按某个View就会弹出相应菜单,当然前提是应用程序有实现菜单功能. Android平台下的菜单有:Options Menu(选项菜单).Subme ...
- android学习日记17--Gallery(画廊视图)
一.Gallery 1.简述 Gallery有道翻译为画廊,就叫它画廊控件,主要用来可切换的图片展示,左右滑动可以选择上一张或下一张图片. 个人感觉蛮实用的,不过google貌似不推荐使用啊! 2.常 ...
- 【转】C++ char数组转化为string
有很多种方法: 假设c字符串定义为char ch[]="hello world!"; 1.向构造函数传入c字符串创建string对象: string str(ch); 2.使用拷贝 ...
- Spring3之JDBC
Spring提供了统一的数据访问异常层次体系,所涉及到的大部分异常类型都定义在org.springframework.dao包中,出于这个体系中所有异常类型均以org.springframework. ...