简体   繁体   English

正确包含GLib标头和自动工具

[英]Properly include GLib headers with autotools

In my normal dev environment (ubuntu), I don't have any issues linking against GLib-2.0, however when I attempt to build on fresh install of Debian Squeeze, I run into errors linking GLib. 在正常的开发环境(ubuntu)中,与GLib-2.0链接时没有任何问题,但是,当我尝试在全新安装的Debian Squeeze上构建时,遇到了链接GLib的错误。

configure.ac: configure.ac:

...
AC_PROG_CC
AM_PROG_CC_C_O
CFLAGS="$CFLAGS -Wall -W -Wno-unused-parameter -std=c99 -pedantic"

PKG_CHECK_MODULES(MYAPP, [glib-2.0 >= 2.3.0  gthread-2.0])

LIBS="$LIBS $MYAPP_LIBS"

AC_CONFIG_FILES([Makefile src/Makefile])
AC_OUTPUT

Autotools appears to pass the correct options to gcc: 自动工具似乎可以将正确的选项传递给gcc:

-I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -lgthread-2.0 -lglib-2.0

However, running make I get a compile error: undefined reference to 'g_list_free_full' 但是,运行make会出现编译错误: undefined reference to 'g_list_free_full'

To verify the libraries are actually installed: 要验证库是否已实际安装:

$ dpkg --get-selections | grep glib
libglib2.0-0                    install
libglib2.0-data                 install
libglib2.0-dev                  install

Any thoughts? 有什么想法吗?

Something to notice: 注意事项:

   stormfs_LDADD = $(LIBS) $(LIBGCRYPT_LIBS)
>> stormfs_LDFLAGS = $(STORMFS_LIBS)                                               

(See Linker flags in wrong place here on SO.) (请参见链接器标志在此处错误的位置 。)
That ought to be: 应该是:

stormfs_LDADD = ${LIBS} ${LIBGCRYPT_LIBS} ${STORMFS_LIBS}

(That is however sort of redundant because both LIBS and STORMFS_LIBS contain the same value, just as I looked at the generated Makefile.) (但是,这有点多余,因为就像我查看生成的Makefile一样,LIBS和STORMFS_LIBS都包含相同的值。)

Edit: 编辑:

nm -D /usr/lib64/libglib-2.0.so | grep g_list_free_full
0000000000042740 T g_list_free_full

So libglib.so (your path to it may vary) does include g_list_free_full in at least glib2-2.30.1. 因此libglib.so(您的访问路径可能有所不同)的确至少在g_list_free_full中包含g_list_free_full。 According to the documentation, this function is only available since glib2-2.28, but your installation is likely just too old. 根据文档,此功能仅自glib2-2.28起可用,但是您的安装可能太旧了。 Best use (and preferably just one pkg dependency per variable, to ease detection of what exactly of the [deps] part could not be found): 最佳使用(最好是每个变量只有一个pkg依赖性,以简化对[deps]部分确切位置的检测):

#configure.ac
PKG_CHECK_MODULES([libgthread], [gthread-2.0])
PKG_CHECK_MODULES([libglib], [glib-2.0 >= 2.28])

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM