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 ...
随机推荐
- 使用ApplicationLoader中出现报错:The IPA is invalid. It does not inlude a Payload directory
问题处理方法: 1.将achieve的.app后缀的软件包放在一个payload的文件夹中 2.压缩该文件夹,改变.zip后缀为.ipa 3.使用applicationLoader上传该文件
- 编码问题(utf-8,gbk,utf-16be)
utf-16be编码 中文汉字 英文字母 还有数字都是占用两个字节( java 是双字节编码 ) gbk编码 中文汉字占用2个字节:英文字母.数字占用一个字节 utf-8编码 中文汉字占用3个字节 ...
- cas 3.5.2 登录成功后,如何返回用户更多信息?
国内私募机构九鼎控股打造APP,来就送 20元现金领取地址:http://jdb.jiudingcapital.com/phone.html内部邀请码:C8E245J (不写邀请码,没有现金送)国内私 ...
- 教你50招提升ASP.NET性能(九):显式的使用using语句减少内存泄露
(15)Reduce memory leaks dramatically with the “using” statement 招数15: 显式的使用using语句减少内存泄露 If a type i ...
- cocos2d-x RenderTexture
转自:http://blog.csdn.net/bill_man/article/details/7250911 1.CCRenderTexture 使用CCRenderTexture的过程总结起来一 ...
- 【51】编写new和delete时需固守常规
1.[50]讲了,有很多理由需要写个自定义的new/delete,自定义new/delete的时候,需要遵守一些规则. 2.循环申请,直到成功或者抛出异常,如下: void* operator new ...
- Codeforces Round #324 (Div. 2) B. Kolya and Tanya 快速幂
B. Kolya and Tanya Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/584/pro ...
- DTCC2016
http://pan.baidu.com/share/home?uk=4043574767#category/type=0
- C 高级编程5 IO与文件权限
三.基于文件的描术符号 .得到文件描术符号/释入文件描术符号 a.文件类型 目录文件 d 普通文件 f 字符设务文件 c 块设备文件 b 软连接文件 l 管道文件 p socket文件 s 字符设备文 ...
- mvc ajax_返回数据
假设cshtml文件中是这样的: <script type="text/javascript"> $(document).ready(function(){ $(&qu ...