未找到 glib.h 和 gtk.h
大家好,我有一个包含以下内容的程序:
- gtk/gtk.h
- glib.h
我已经使用了这些命令:
sudo apt-get install libgtk2.0-dev glib
sudo apt-get install glade
但我仍然收到错误,未找到 glib 且未找到 gtk/gtk.h。这是我第一次使用 gtk,我不知道它是如何工作的,也不知道如何安装它。
Hi everyone I have a program with the following includes:
- gtk/gtk.h
- glib.h
I have used the commands:
sudo apt-get install libgtk2.0-dev glib
sudo apt-get install glade
But I am still getting the error that glib was not found and gtk/gtk.h was not found. It's the first time I am using gtk and I have no idea how it works or how to install it.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您应该使用的命令(在最新版本的 linux/gtk 中)是 pkg-config,而不是 gtk-config。 gtk-config 旨在用于 2.0 之前的 gtk 开发。
考虑您正在编译的文件名为 foo.c,要在 gtk-2.0 下编译它,您可以从命令行使用以下命令:
这应该编译,并为您提供一个可以执行的文件 foo。
但实际上,请使用 makefile,因为继续输入这些东西很痛苦。我会写出一个示例 makefile,但是在格式化它们时需要遵循一些规则,这使得在编辑器窗口中键入变得困难。
这里定义了一个简单的规则,说要制作 foo,它依赖于 foo.c,所以 foo.c 比 foo 新,它将被重建。在我写“TAB HERE NOT SPACES”的地方,它必须是一个制表符,并且不能是一组空格字符。
The command you're supposed to use (in more recent releases of linux/gtk) is pkg-config, not gtk-config. gtk-config is intended for pre 2.0 gtk development.
Consider the file you're compiling is called foo.c, to compile it under gtk-2.0, you would use, from the command line the command:
This should compile, and give you a file foo, that can be executed.
but really, use a makefile, as this stuff is a pain to keep typing. I would write out a sample makefile, but there are rules that need to be followed in the formatting of them that makes it difficult to type in the editor window.
This defines a simple rule saying to make foo, it depends on foo.c, so of foo.c is newer than foo, it will be rebuilt. Where I write 'TAB HERE NOT SPACES' it must be a tab character, and cannot be a set of space characters.
输入“locate glib.h”来确定文件的位置(假设是当代的 Linux 发行版 - 您的帖子没有提供太多信息)。
然后确保在 Makefile 中正确指定了 glib.h 的路径。 (您确实有 Makefile,不是吗?)对 gtk.h 执行相同的步骤。
type "locate glib.h" to determine file's location (assuming a contemporary linux distribution - your post doesn't provide much information).
Then ensure the path to glib.h is properly specified in your Makefile. (You do have a Makefile, don't you?) Perform the same steps for gtk.h.
请阅读官方文档。它解释了如何编译 GTK 应用程序。
基本上,要编译
hello.c
文件以生成hello
程序,您需要输入:Please read the official documentation. It explains how to compile GTK applications.
Basically to compile a
hello.c
file to generate ahello
program, you'll type: