I am having some issues compiling Glib. These are my configure options that I have passed to ./configure:

./configure LIBFFI_LIBS=/usr/local/lib/libffi.so.6 LIBFFI_CFLAGS=-I/usr/local/lib/libffi-3.0.11/include LIBFFI_CFLAGS=-L/usr/local/lib ZLIB_LIBS=/usr/local/lib/ ZLIB_CFLAGS=/usr/local/include/ CC=/usr/bin/gcc

and this is the error that I get when I run the make command

make[4]: Entering directory `/home/joe/Downloads/glib-2.32.4/gobject'
CCLD   gobject-query
./.libs/libgobject-2.0.so: undefined reference to `ffi_type_pointer'
./.libs/libgobject-2.0.so: undefined reference to `ffi_type_float'
./.libs/libgobject-2.0.so: undefined reference to `ffi_type_void'
./.libs/libgobject-2.0.so: undefined reference to `ffi_type_sint64'
./.libs/libgobject-2.0.so: undefined reference to `ffi_prep_cif'
./.libs/libgobject-2.0.so: undefined reference to `ffi_type_uint32'
./.libs/libgobject-2.0.so: undefined reference to `ffi_type_double'
./.libs/libgobject-2.0.so: undefined reference to `ffi_call'
./.libs/libgobject-2.0.so: undefined reference to `ffi_type_sint32'
./.libs/libgobject-2.0.so: undefined reference to `ffi_type_uint64'
collect2: ld returned 1 exit status
make[4]: *** [gobject-query] Error 1
make[4]: Leaving directory `/home/joe/Downloads/glib-2.32.4/gobject'
make[3]: *** [all-recursive] Error 1
make[3]: Leaving directory `/home/joe/Downloads/glib-2.32.4/gobject'
make[2]: *** [all] Error 2
make[2]: Leaving directory `/home/joe/Downloads/glib-2.32.4/gobject'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/home/joe/Downloads/glib-2.32.4'
make: *** [all] Error 2

closed as off topic by mdpc, Scott Pack, Jenny D, Khaled, Ward Mar 29 '13 at 6:24

Questions on Server Fault are expected to relate to server, networking, or related infrastructure administration within the scope defined by the community. Consider editing the question or leaving comments for improvement if you believe the question can be reworded to fit within the scope. Read more about reopening questions here. If this question can be reworded to fit the rules in the help center, please edit the question.

  • 1
    Run the make with a V=1 argument so you can see the actual linker command line instead of that "CCLD" garbage. You need to find out if it's actually using the /usr/local/lib/libffi.so.6 you gave it. Also check the lib file to see of those symbols are in there: objdump -T /usr/local/lib/libffi.so.6 | grep ffi_type_pointer – Alan Curry Jul 26 '12 at 21:36
  • This worked for me: export LIBFFI_LIBS="-L/your/path/to-ffi libraries/ -lffi" See stackoverflow.com/questions/18104269/… – Joao Costa Oct 4 '18 at 11:50

I know that this is pretty old, but I ran into the same problem. The fix I had was, rather than go into the Makefiles, I went in and modified the Makefile.in files (my installed version of autotools was too low to autoreconf, otherwise I would have modified the Makefile.am files). These modifications were associated with glib-2.34.1 tarball Anyway, the modifications were as follows:

gobject/Makefile.in: line 629

progs_LDADD = ./libgobject-2.0.la $(libglib) $(LIBFFI_LIBS)

gobject/tests/Makefile.in: line 461

LDADD = ../libgobject-2.0.la $(top_builddir)/gthread/libgthread-2.0.la $(top_builddir)/glib/libglib-2.0.la $(LIBFFI_LIBS)

gio/Makefile.in: I added $(LIBFFI_LIBS) to the end of many *_LDADD definitions (some of which were likely unnecessary), which were on the following lines: 1292, 1305 (before backslash), 1319, 1327, 1340

gio/tests/Makefile.in: line 1073 (part of a multi-line assignment)

     $(top_builddir)/gio/libgio-2.0.la $(LIBFFI_LIBS)

built using the command:

./configure --prefix=$APP/glib/2.34.1 --enable-man=no LIBFFI_CFLAGS=-I$APP/libffi/3.0.11/lib/libffi-3.0.11/include LIBFFI_LIBS=$APP/libffi/3.0.11/lib/libffi.la && make && make install

The --enable-man=no was due to another error I came across, and I'm not worried about not having access to man pages associated with this. I actually deleted the version that I had previously built/installed, applied these modifications and built and it worked.

In any case, I think that these modifications would likely take less time than modifying the relevant lines in the Makefiles, (especially gio/tests/Makefile). It might also provide a place to start in terms of modifying the Makefile.am files for the autoconf.

  • I get make[4]: *** No rule to make target -L/usr/local/lib/libffi.la', needed by gobject-query'. Stop. :( – Cocowalla Jun 21 '14 at 21:25

You are missing the development files (headers, libs) for libffi.

To install them, install the libffi-devel (RedHat-type) or libffi-dev (Debian-type) package.

  • Hey Guys thanks for responding but it still will not work I have done exactly what both of you have said and still no joy – joe Jul 31 '12 at 18:10
  • Did you re-run ./configure (without your interfering options)? – Michael Hampton Jul 31 '12 at 18:10
  • Hey Michael no I didn't becuase if I do without my options it complains that it cannot find libffi.h etc... if it helps I am using Centos 6.2 – user1219128 Aug 1 '12 at 15:03
  • 1
    Maybe we should be asking why you're recompiling a system package, and having to use custom versions of other libraries to do it, then? – Michael Hampton Aug 1 '12 at 15:09

I got this working.

It took hacking through each individual Makefile in the glib source directories and adding an absolute path that pointed to libffi.la. I had to do this for each gcc line that produced this error. There were... many.

I would run make V=1 J=1 to find the next line that needed the libffi functions and then fix it. It seems like whoever wrote the makefiles / automake configuration scripting left that part out...

It was terrible and I don't know how to trace back to the seed of this to fix it in an elegant way, but this got it working in less than an hour.

Not the answer you're looking for? Browse other questions tagged or ask your own question.