GLib compile error (ffi.h), but libffi is installed

GtkGlib

Gtk Problem Overview


After a succesful configure, make exits with snipped

gclosure.c:29:17: fatal error: ffi.h: No such file or directory
compilation terminated.

I have libffi installed, and locate ffi.h gives:

/home/luca/gcc4.6/gcc-4.6.0/libffi/include/ffi.h.in
/usr/include/x86_64-linux-gnu/ffi.h
/usr/share/doc/ghc-doc/html/users_guide/ffi.html
/usr/share/doc/libffi5/html/Using-libffi.html

Gtk Solutions


Solution 1 - Gtk

If you have a Debian-based Linux OS with apt-get:

sudo apt-get install libffi-dev

With a Redhat-base OS:

yum install libffi-devel

With Alpine Linux:

apk add libffi-dev

Solution 2 - Gtk

When compling libffi 3.0.9 from source code, the include/Makefile.in installs the includes in the ${PREFIX}/lib/libffi-3.0.9/include directory. I'm sure there's a WONDERFUL reason for that, but I'm annoyed by it.

This line fixes it, when compiling libffi:

/bin/perl -pe 's#^includesdir = .*#includesdir = \@includedir\@#' -i include/Makefile.in

The includes will now be installed in ${PREFIX}/include, which is /usr/local/include for me.

My full recipe is:

cd /var/tmp
rm -rf libffi-3.0.9
untgz /usr/local/src/utils/libffi-3.0.9.tar.gz
cd libffi-3.0.9
/bin/perl -pe 's#^AM_CFLAGS = .*#AM_CFLAGS = -g#' -i Makefile.in
/bin/perl -pe 's#^includesdir = .*#includesdir = \@includedir\@#' -i include/Makefile.in
./configure --prefix=/usr/local \
    --includedir=/usr/local/include
gmake
gmake install

Solution 3 - Gtk

Resolved by manually setting LIBFFI_CFLAGS for location of ffi.h in configure

Solution 4 - Gtk

Check your GCC version and note this entry in the Debian Bug Archive: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=523869

It was the final solution to my particular issue (it looked exactly like what you report, but couldn't be solved with the solution above)... my problem had nothing to do with LIBFFI at all.

Solution 5 - Gtk

An old thread, but anyway...

After putting the required files in a location where they could be found, I got it working:

cp /usr/include/x86_64-linux-gnu/ffi* /usr/local/include/
cp /usr/lib/libffi.so /usr/local/lib/

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestiondeltalucaView Question on Stackoverflow
Solution 1 - GtkEric Milliot-MartinezView Answer on Stackoverflow
Solution 2 - GtkMark SolarisView Answer on Stackoverflow
Solution 3 - GtkdeltalucaView Answer on Stackoverflow
Solution 4 - GtkmindwarpstudiosView Answer on Stackoverflow
Solution 5 - GtkHammarView Answer on Stackoverflow