首页 文章

GTK使Cygwin错误

提问于
浏览
0

香港专业教育学院刚做了这么多研究,尝试了很多,但没有任何作用我正在尝试使用make在Cygwin中的GTK中编译一个简单的hello world程序 . 它给了我错误:“lab0.c:1:21:错误:gtk / gtk.h:没有这样的文件或目录....”我安装了所有包的cygwin . 我还将所有的gtk文件导入到cygwin文件夹中,但它给了我同样的错误 . 这是我的节目:

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工作 . 请帮我 .

2 回答

  • 0

    您需要安装libgtk2.0-devel软件包才能获得开发所需的头文件;您可能只安装了运行时和/或源代码包,这是不够的 .

  • 1

    Adam所说的正确包是cygwin设置中的libgtk2.0-devel包 . 您可以重新运行安装程序并从列表中选择包 . 搜索gtk,你'll find it. I' m实际安装它现在:)
    进入“选择包”屏幕时 . 转到X11并选择上述包 .
    您还可以检查是否同时安装了版本1.2和2.0,可能会导致问题 .

相关问题