一、gtk的部署配置
- gtk bundle包解压至文件夹
- 配置环境变量
3.查询gtk路径是否正确
命令:pkg-config --cflags gtk+-3.0
4.配置GTK本地环境
配置pango:pango-querymodules > d:\gtk\etc\pango\pango.modules
配置 gdk-pixbuf:
gdk-pixbuf-query-loaders > d:\gtk\lib\gdk-pixbuf-2.0\2.10.0\loaders.cache
配置gtk-query-immodules:
gtk-query-immodules-3.0 > d:\gtk\lib\gtk-3.0\3.0.0\immodules.cache
5.运行测试
命令:gtk3-demo
二、gtk与vs的配置
- 新建c++常规空项目
- 源文件新建项
- 项目属性->c/c++ 附加包含目录
D:\gtkbundle_3.4.220130513_win32\lib\glib-2.0\include
D:\gtkbundle_3.4.220130513_win32\include\pixman-1
D:\gtkbundle_3.4.220130513_win32\include\pango-1.0
D:\gtkbundle_3.4.220130513_win32\include\lzma
D:\gtkbundle_3.4.220130513_win32\include\libxml2
D:\gtkbundle_3.4.220130513_win32\include\librsvg-2.0
D:\gtkbundle_3.4.220130513_win32\include\libpng15
D:\gtkbundle_3.4.220130513_win32\include\libcroco-0.6
D:\gtkbundle_3.4.220130513_win32\include\jasper
D:\gtkbundle_3.4.220130513_win32\include\gtk-3.0
D:\gtkbundle_3.4.220130513_win32\include\glib-2.0
D:\gtkbundle_3.4.220130513_win32\include\gio-win32-2.0
D:\gtkbundle_3.4.220130513_win32\include\gdk-pixbuf-2.0
D:\gtkbundle_3.4.220130513_win32\include\gail-3.0
D:\gtkbundle_3.4.220130513_win32\include\freetype2
D:\gtkbundle_3.4.220130513_win32\include\fontconfig
D:\gtkbundle_3.4.220130513_win32\include\cairo
D:\gtkbundle_3.4.220130513_win32\include\atk-1.0
D:\gtkbundle_3.4.220130513_win32\include
4.链接器->常规->附加库目录
D:\gtkbundle_3.4.220130513_win32\lib
5.链接器->输入->附加依赖项
atk-1.0.lib
cairo.lib
fontconfig.lib
gailutil.lib
gdk_pixbuf-2.0.lib
gdk-win32-3.0.lib
gio-2.0.lib
glib-2.0.lib
gmodule-2.0.lib
gobject-2.0.lib
gthread-2.0.lib
gtk-win32-3.0.lib
pango-1.0.lib
pangocairo-1.0.lib
pangoft2-1.0.lib
pangowin32-1.0.lib
6.测试代码
#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 there until the application is closed */
gtk_main();
return 0;
}