Lab0.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 there until the application is closed */
gtk_main ();
return 0;
}
生成文件
# Makefile for Hello World Program (lab0).
all: lab0
lab0: lab0.o
g++ -Wall lab0.o -o lab0
lab0.o: lab0.c
g++ -Wall -c lab0.c -o lab0.o
我真的需要让gtk工作。请帮我。
答案 0 :(得分:1)
您需要安装libgtk2.0-devel软件包才能获得开发所需的头文件;你可能只安装了运行时和/或源代码包,这还不够。
答案 1 :(得分:0)
Adam所说的正确包是cygwin设置中的libgtk2.0-devel包。您可以重新运行安装程序并从列表中选择包。搜索gtk,你会发现它。我现在正在安装它:)
进入“选择包”屏幕时。转到X11并选择上述包装
您还可以检查是否同时安装了版本1.2和2.0,可能会导致问题。