Ubuntu16.04下安装GTK+
2017-03-24 15:36
736 查看
Ubuntu14.04下安装GTK+
新浪微博 http://weibo.com/sageAqi今日头条 https://www.toutiao.com/c/user/3210982668/
微信公众号:
itxxgh (IT学习干货),全公益,免费,提供,学习教程。已经改名为《IT首席技术官》。播正能量,扫码关注首先配置源:
1.备份
cd /etc/apt sudo cp sources.list sources.list.backup
2.用新的文件替换掉soures.list
deb http://mirrors.aliyun.com/ubuntu/ xenial main restricted universe multiverse deb http://mirrors.aliyun.com/ubuntu/ xenial-security main restricted universe multiverse deb http://mirrors.aliyun.com/ubuntu/ xenial-updates main restricted universe multiverse deb http://mirrors.aliyun.com/ubuntu/ xenial-backports main restricted universe multiverse
3.更新
sudo apt-get update
一、安装
1、安装gcc/g++/gdb/make 等基本编程工具
$sudo apt-get install build-essential2、安装 libgtk2.0-dev libglib2.0-dev 等开发相关的库文件
$sudo apt-get install gnome-core-devel3、用于在编译GTK程序时自动找出头文件及库文件位置
$sudo apt-get install pkg-config4、安装 devhelp GTK文档查看程序
$sudo apt-get install devhelp5、安装 gtk/glib 的API参考手册及其它帮助文档
$sudo apt-get install libglib2.0-doc libgtk2.0-doc6、安装基于GTK的界面GTK是开发Gnome窗口的c/c++语言图形库
$sudo apt-get install glade libglade2-dev
或者
$sudo apt-get install glade-gnome glade-common glade-doc7、安装gtk2.0 或者 将gtk+2.0所需的所有文件统通下载安装完毕
$sudo apt-get install libgtk2.0-dev
或者
$sudo apt-get install libgtk2.0*二、查看GTK库版本
1、查看 2.x 版本
$pkg-config --modversion gtk+-2.02、查看pkg-config的版本
$pkg-config --version3、查看是否安装了gtk
$pkg-config --list-all grep gtk三、测试程序
//Hello.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 Hello Hello.c `pkg-config --cflags --libs gtk+-2.0` 标注部分一定要加上不然编译错误。 其中的‘’不是单引号而是Tab键上边那个·2、运行
$./Hello
相关文章推荐
- Ubuntu16.04 - 安装gtk+-3.0和appindicator3-0.1
- 怎样在Ubuntu16.04上安装GTK+-3.0
- Ubuntu下安装GTK+
- Ubuntu 下GTK+开发环境的安装
- 如何在 Ubuntu 16.04,15.10,14.04 中安装 GIMP 2.8.16
- ubuntu16.04下安装wireshark(以及配置非root)
- Ubuntu16.04安装Eclipse EE
- [搬家帖]Ubuntu下安装GTK+
- 自己学Docker:1.Docker安装--基于Ubuntu16.04
- Ubuntu下面安装GTK+
- ubuntu安装GTK+的三种方法
- ubuntu16.04 jdk环境变量配置和安装android studio
- Ubuntu 下面安装gtk+-2.0
- ubuntu下安装gtk+
- Ubuntu下安装GTK+步骤
- Ubuntu 下面安装gtk+-2.0
- Ubuntu 下安装GTK+
- Ubuntu下安装GTK+
- Ubuntu 源码安装gtk+-2.0
- ubuntu14.04 gtk+安装与常见错误