GTK+使 Cygwin 错误
我刚刚做了很多研究并尝试了很多,但没有任何效果。我正在尝试使用 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
# 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 工作。请帮我。
ive just done so much research and tried so much but nothing works. I am trying to compile a simple hello world program in GTK in Cygwin using make. It gives me error: "lab0.c:1:21: error: gtk/gtk.h: No such file or directory...."
I installed cygwin with all packages. I also imported the all in one gtk files into the cygwin folders but it gives me same error. Here are my programs:
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
# 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
I really need to get gtk working. Please help me.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
需要安装libgtk2.0-devel包来获取开发所需的头文件;您可能只安装了运行时和/或源代码包,这是不够的。
You need to install the libgtk2.0-devel package to get the header files you need for development; you probably only installed the runtime and/or source code packages, which are not sufficient.
Adam 所说的正确包是 cygwin 设置中的 libgtk2.0-devel 包。您可以重新运行安装程序并从列表中选择软件包。搜索gtk,你就会找到它。我现在实际上正在安装它:)
当您进入“选择包”屏幕时。转到 X11 并选择上述包。
您还可以检查一下您是否同时安装了1.2和2.0版本,也许会导致问题。
The proper package as Adam stated is the libgtk2.0-devel package in the cygwin setup. You can rerun the setup program and select the package from the list. Search for gtk and you'll find it. I'm actually installing it right now :)
When you get to the Select Packages screen. Go to X11 and select the aforementioned package.
You can also check if you have versions 1.2 and 2.0 installed at the same time, maybe it could cause problems.