【问题标题】:maemo scratchbox compiler error with gtk+-2.0gtk+-2.0 的 maemo scratchbox 编译器错误
【发布时间】:2010-11-10 04:49:00
【问题描述】:

我正在尝试遵循第 3.4.2 节,从 this manual 的第 31 页开始。但是,由于我已将目标配置为 DIABLO_ARMEL 而不是 DIABLO_X86,因此该命令得到了不同的结果:

[sbox-DIABLO_X86: ~] > gcc -Wall -g gtk_helloworld-1.c \
 ‘pkg-config --cflags gtk+-2.0‘ -o gtk_helloworld-1 \
 ‘pkg-config --libs gtk+-2.0‘
[sbox-DIABLO_X86: ~] >

在输入此行之前,我已经检查了单引号中命令的 cflags 和 libs 结果,以及示例中描述的结果与我在命令窗口中看到的结果之间的结果。

无论如何,我不希望在终端中弹出错误消息,但我得到了以下信息:

[sbox-DIABLO_ARMEL: ~] > gcc -Wall -g gtk-helloworld-1.c \
> 'pkg-config --cflags gtk+-2.0' -o gtk_helloworld-1 \
> 'pkg-config --libs gtk+-2.0'
sbox-arm-linux-gcc: pkg-config --cflags gtk+-2.0: No such file or directory
sbox-arm-linux-gcc: pkg-config --libs gtk+-2.0: No such file or directory
gtk-helloworld-1.c:15:21: gtk/gtk.h: No such file or directory
gtk-helloworld-1.c: In function `main':
gtk-helloworld-1.c:20: error: `GtkWindow' undeclared (first use in this function)
gtk-helloworld-1.c:20: error: (Each undeclared identifier is reported only once
gtk-helloworld-1.c:20: error: for each function it appears in.)
gtk-helloworld-1.c:20: error: `window' undeclared (first use in this function)
gtk-helloworld-1.c:21: error: `GtkLabel' undeclared (first use in this function)
gtk-helloworld-1.c:21: error: `label' undeclared (first use in this function)
gtk-helloworld-1.c:24: warning: implicit declaration of function `gtk_init'
gtk-helloworld-1.c:28: warning: implicit declaration of function `g_object_new'
gtk-helloworld-1.c:28: error: `GTK_TYPE_WINDOW' undeclared (first use in this function)
gtk-helloworld-1.c:34: error: `GTK_TYPE_LABEL' undeclared (first use in this function)
gtk-helloworld-1.c:39: warning: implicit declaration of function `gtk_container_add'
gtk-helloworld-1.c:39: warning: implicit declaration of function `GTK_CONTAINER'
gtk-helloworld-1.c:39: warning: implicit declaration of function `GTK_WIDGET'
gtk-helloworld-1.c:42: warning: implicit declaration of function `gtk_widget_show_all'
gtk-helloworld-1.c:45: warning: implicit declaration of function `g_print'
gtk-helloworld-1.c:46: warning: implicit declaration of function `gtk_main'

我不确定在包含和库路径配置方面我做错了什么。如果有人可以提供一些修复此错误的提示,那就太好了。提前致谢。

【问题讨论】:

    标签: c compiler-construction maemo scratchbox


    【解决方案1】:

    您需要在 pkg-config 周围加上反引号:

    gcc -Wall -g gtk-helloworld-1.c `pkg-config --cflags gtk+-2.0`... -o gtk ...
    

    【讨论】:

    • 我不知道我是否理解你的建议,但我尝试输入 gcc -Wall -g gtk-helloworld-1.c 'pkg-config --cflgas gtk+-2.0' -o gtk-helloworld-1 'pkg-config --libs gtk+-2.0' 全部在一行中,仍然无法构建程序。我要检查我是否有正确的包裹。
    • 你又忘记了反引号...'是引号`是反引号:)
    • 或者如果反引号有问题,请使用如下语法运行 pkg-config:$(pkg-config --cflags gtk+-2.0)
    猜你喜欢
    • 2010-12-27
    • 2011-01-10
    • 1970-01-01
    • 1970-01-01
    • 2017-06-11
    • 2014-11-26
    • 1970-01-01
    • 1970-01-01
    • 2010-11-26
    相关资源
    最近更新 更多