【问题标题】:Glib C : program does not recognize GLIB libraryGlib C:程序无法识别 GLIB 库
【发布时间】:2014-04-11 23:07:26
【问题描述】:

当我想编译我的 C 程序时,我遇到了问题。它适用于 Ubuntu 11.04,但是当我迁移到 Ubuntu 13 时,我遇到了这个问题。

我用这个 Makefile 编译:

all:
    gcc -D_GNU_SOURCE -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include \
    -I/usr/lib/x86_64-linux-gnu/glib-2.0/include/ -lglib-2.0 -D_FILE_OFFSET_BITS=64 \
    -D_LARGEFILE_SOURCE -g -Wall -Wextra -std=c99 -lm *.c -o concatener

我收到以下错误:

undefined reference to « g_str_equal »
undefined reference to « g_str_equal »
undefined reference to « g_array_remove_index »
undefined reference to « g_array_remove_index »

为什么它不能识别这些功能?我是否链接到 glib 库错误?

【问题讨论】:

    标签: c glib


    【解决方案1】:

    gcc 命令看起来不错,我看不出有什么明显错误,与-lglib-2.0 链接应该是您想要的1

    我的猜测是,在您的 Ubuntu 11.04 系统上,您安装了 glib 开发包,而在您的 13 系统上未安装它。我认为包名应该是 libglib2.0-dev。


    1 如果您想更通用一点,可以将硬编码的编译和链接选项替换为

    `pkg-config --cflags glib-2.0`
    

    `pkg-config --libs glib-2.0`
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-09-08
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多