本文介绍了为什么我不能建立一个"世界你好"对于油嘴滑舌?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

因此​​,这里是世界上最简单巧舌如簧程序:

So here's the world's simplest glib program:

#include <glib.h>

我尝试用海合会test.c以编译它,我也得到:

test.c:1:18: error: glib.h: No such file or directory

所以我确保我有合适的包:

So I make sure that I have the right packages:

# dpkg -l | grep libglib
ii  libglib-perl                              1:1.183-1                               Perl interface to the GLib and GObject libra
ii  libglib1.2-dev                            1.2.10-19build1                         The GLib library of C routines (development)
ii  libglib1.2ldbl                            1.2.10-19build1                         The GLib library of C routines
ii  libglib2.0-0                              2.20.1-0ubuntu2                         The GLib library of C routines
ii  libglib2.0-cil                            2.12.1-1ubuntu2                         CLI binding for the GLib utility library 2.1
ii  libglib2.0-data                           2.18.2-0ubuntu2                         Common files for GLib library
ii  libglib2.0-dev                            2.20.1-0ubuntu2                         Development files for the GLib library
ii  libglibmm-2.4-1c2a                        2.18.1-1                                C++ wrapper for the GLib toolkit (shared lib

然后我搜索任何glib.h下的任何地方/ usr / include目录。我得到两个,/usr/include/glib-1.2/glib.h和/usr/include/glib-2.0/glib.h。所以我尝试:

Then I search for any "glib.h" anywhere under /usr/include. I get two, /usr/include/glib-1.2/glib.h and /usr/include/glib-2.0/glib.h. So I try:

$ gcc -I/usr/include/glib-2.0 -Wall test.c  
In file included from /usr/include/glib-2.0/glib/galloca.h:34,
             from /usr/include/glib-2.0/glib.h:32,
             from test.c:2:
/usr/include/glib-2.0/glib/gtypes.h:34:24: error: glibconfig.h: No such file or directory

(剪断约10000多个错误)

(about 10,000 more errors snipped)

我不似乎有一个 glibconfig.h 的任何地方我的电脑上。

I don't seem to have a glibconfig.h anywhere on my computer.

现在我该怎么办?

推荐答案

巧舌如簧往往隐藏自身...您的包含语句不起作用,因为GCC不会自动搜索子目录,所以无法看到glib.h巧舌如簧-1.2或巧舌如簧-2.0。

glib tends to hide itself... Your include statement doesn't work because GCC doesn't automatically search subdirectories, and so cannot see the glib.h in glib-1.2 or glib-2.0.

阅读页面...您使用像命令 pkg配置--cflags能说会道,2.0 来得到正确的标志GCC。

Read the Compiling GLib Applications page in the GLIB manuals... you use commands like pkg-config --cflags glib-2.0 to get the right flags for GCC.

的规范的方式做你正在尝试的是

The canonical way to do what you are trying is

% gcc test.c -Wall -o test `pkg-config --cflags --libs glib-2.0`

请注意背蜱,它告诉shell运行就地在pkg-config命令。

Note the back-ticks, which tell the shell to run the pkg-config command "in-place".

这篇关于为什么我不能建立一个&QUOT;世界你好&QUOT;对于油嘴滑舌?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-12 20:59