diff --git a/c3s/configure b/c3s/configure
index 41bb404..4fc719c 100755
--- a/c3s/configure
+++ b/c3s/configure
@@ -50,10 +50,11 @@ LIBS="${LIBS:=-lm}"
# Common config for all targets
CFLAGS="$CFLAGS -W -Wall -Werror -std=c99 -pedantic"
+CPPFLAGS="$CPPFLAGS -I../libffi/include"
+LIBS="$LIBS -L../libffi/.libs/ -lffi"
config_asan
config_gnu
pkg_config libbsd-overlay
-pkg_config libffi
pkg_config libmd
config_lib libmd -lmd
config_lib dl -ldl
diff --git a/ic3/configure b/ic3/configure
index fb66fba..d4dbbbf 100755
--- a/ic3/configure
+++ b/ic3/configure
@@ -50,10 +50,11 @@ LIBS="${LIBS:=-lm}"
# Common config for all targets
CFLAGS="$CFLAGS -W -Wall -Werror -std=c99 -pedantic"
+CPPFLAGS="$CPPFLAGS -I../libffi/include"
+LIBS="$LIBS -L../libffi/.libs/ -lffi"
config_asan
config_gnu
pkg_config libbsd-overlay
-pkg_config libffi
pkg_config libmd
config_lib libmd -lmd
config_lib dl -ldl
diff --git a/libc3/configure b/libc3/configure
index 9524860..9e61d8d 100755
--- a/libc3/configure
+++ b/libc3/configure
@@ -39,6 +39,7 @@ LIBS="${LIBS} -lm -pthread -rpath ${PREFIX}/lib"
# Common config for all targets
CFLAGS="$CFLAGS -W -Wall -Werror -std=c99 -pedantic -fPIC"
+CPPFLAGS="$CPPFLAGS -I../libffi/include"
config_asan
config_gnu
pkg_config libbsd-overlay
diff --git a/libc3/types.h b/libc3/types.h
index 3fa43f6..ecc29ee 100644
--- a/libc3/types.h
+++ b/libc3/types.h
@@ -13,6 +13,7 @@
#ifndef TYPES_H
#define TYPES_H
+#include <ffi.h>
#include <limits.h>
#include <setjmp.h>
#include <stdio.h>
@@ -20,7 +21,6 @@
#include <pthread.h>
#include "config.h"
#include "sha1.h"
-#include "../libffi/include/ffi.h"
#include "../libtommath/tommath.h"
/* Basic integer types. */
diff --git a/test/configure b/test/configure
index 9587ee9..450236b 100755
--- a/test/configure
+++ b/test/configure
@@ -50,10 +50,11 @@ LIBS="${LIBS:=} -lm"
# Common config for all targets
CFLAGS="$CFLAGS -W -Wall -Werror -std=c99 -pedantic"
+CPPFLAGS="$CPPFLAGS -I../libffi/include"
+LIBS="$LIBS -L../libffi/.libs/ -lffi"
config_asan
config_gnu
pkg_config libbsd-overlay
-pkg_config libffi
pkg_config libmd
config_lib libmd -lmd
config_lib dl -ldl