0

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.

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:

-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'

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?

ben lemasurier
  • 2,582
  • 4
  • 22
  • 37
  • You should show us your `Makefile.am` (if using automake) or `Makefile.in` (if not). Also show `src/Makefile.am` or `src/Makefile.in`. – Jack Kelly Jan 23 '12 at 22:14
  • 1
    Full source can be found here: https://github.com/benlemasurier/stormfs I stripped some data from the post for brevity – ben lemasurier Jan 23 '12 at 22:19
  • 1
    You *MUST NOT* ASSIGN CFLAGS in configure.ac. CFLAGS is a user variable, and the user running the configure script should not have their assignment of CFLAGS overridden. See http://www.gnu.org/software/automake/manual/html_node/User-Variables.html – William Pursell Jan 24 '12 at 23:39
  • curl/types.h is removed at [2ef7a28a71](https://github.com/bagder/curl/commit/2ef7a28a71). It'd better not to use it. Otherwise, it will not compile after Debian Squeeze. – Yasushi Shoji Aug 18 '12 at 15:51
  • Just curios, who is using `g_list_free_full`? – Yasushi Shoji Aug 18 '12 at 15:57

1 Answers1

3

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.)

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. According to the documentation, this function is only available since glib2-2.28, but your installation is likely just too old. Best use (and preferably just one pkg dependency per variable, to ease detection of what exactly of the [deps] part could not be found):

#configure.ac
PKG_CHECK_MODULES([libgthread], [gthread-2.0])
PKG_CHECK_MODULES([libglib], [glib-2.0 >= 2.28])
Community
  • 1
  • 1
jørgensen
  • 10,149
  • 2
  • 20
  • 27