A Portable Foreign Function Interface Library
libffi-3.2.1 was released on November 12, 2014. You can ftp it from

libffi is free software. It has a very liberal license.

What is libffi?

Compilers for high level languages generate code that follows certain conventions. These conventions are necessary, in part, for separate compilation to work. One such convention is the "calling convention". The "calling convention" is a set of assumptions made by the compiler about where function arguments will be found on entry to a function. A "calling convention" also specifies where the return value for a function is found.

Some programs may not know at the time of compilation what arguments are to be passed to a function. For instance, an interpreter may be told at run-time about the number and types of arguments used to call a given function. Libffi can be used in such programs to provide a bridge from the interpreter program to compiled code.

The libffi library provides a portable, high level programming interface to various calling conventions. This allows a programmer to call any function specified by a call interface description at run-time.

FFI stands for Foreign Function Interface. A foreign function interface is the popular name for the interface that allows code written in one language to call code written in another language. The libffi library really only provides the lowest, machine dependent layer of a fully featured foreign function interface. A layer must exist above libffi that handles type conversions for values passed between the two languages.

Who uses it?

The libffi library is useful to anyone trying to build a bridge between interpreted and natively compiled code. Some notable users include:

Supported Platforms

Libffi has been ported to many different platforms. For specific configuration details and testing status, please refer to the README file. At the time of release, the following basic configurations have been tested:

ArchitectureOperating System
AArch64 (ARM64) iOS
AArch64 Linux
Alpha Linux
Alpha Tru64
ARC Linux
ARM Linux
AVR32 Linux
Blackfin uClinux
IA-64 Linux
M68K FreeMiNT
M68K Linux
M68K OpenBSD/mvme88k
Meta Linux
MicroBlaze Linux
MIPS Linux
MIPS64 Linux
Moxie Bare metal
Nios II Linux
OpenRISC Linux
PowerPC 32-bit AIX
PowerPC 64-bit AIX
PowerPC 32-bit Linux
PowerPC 64-bit Linux
PowerPC Mac OSX
PowerPC 32-bit FreeBSD
PowerPC 64-bit FreeBSD
S390 Linux
S390X Linux
SPARC Solaris
SPARC64 Linux
SPARC64 Solaris
VAX OpenBSD/vax
X86 FreeBSD
X86 Interix
X86 kFreeBSD
X86 Linux
X86 Mac OSX
X86 OpenBSD
X86 OS/2
X86 Solaris
X86 Windows/Cygwin
X86 Windows/MingW
X86-64 FreeBSD
X86-64 Linux
X86-64 Linux/x32
X86-64 OpenBSD
X86-64 Solaris
X86-64 Windows/Cygwin
X86-64 Windows/MingW
Xtensa Linux

Please send additional platform test results to and feel free to update the wiki page above.

How to get it

You can download the latest version from

You can also check out the very latest version from the development git repository at Here's how:

  git clone git://
You can also browse the sources at

Mailing lists

For such a small piece of software, there are plenty of mailing lists available.

To subscribe to the libffi-announce mailing list, enter your e-mail address:

To subscribe to the libffi-discuss mailing list, enter your e-mail address:

Authors and Credits

libffi was originally written by Anthony Green

The developers of the GNU Compiler Collection project have made innumerable valuable contributions. See this ChangeLog files in the source distribution for details.

Some of the ideas behind libffi were inspired by Gianni Mariani's free gencall library for Silicon Graphics machines.

The closure mechanism was designed and implemented by Kresten Krab Thorup.

Major processor architecture ports were contributed by the following developers:

aarch64		Marcus Shawcroft, James Greenhalgh
alpha		Richard Henderson
arm		Raffaele Sena
blackfin        Alexandre Keunecke I. de Mendonca
cris		Simon Posnjak, Hans-Peter Nilsson
frv		Anthony Green
ia64		Hans Boehm
m32r		Kazuhiro Inaoka
m68k		Andreas Schwab
microblaze	Nathan Rossi
mips		Anthony Green, Casey Marshall
mips64		David Daney
moxie		Anthony Green
nios ii		Sandra Loosemore
openrisc        Sebastian Macke
pa		Randolph Chung, Dave Anglin, Andreas Tobler
powerpc		Geoffrey Keating, Andreas Tobler, 
			 David Edelsohn, John Hornkvist
powerpc64	Jakub Jelinek
s390		Gerhard Tonn, Ulrich Weigand
sh		Kaz Kojima
sh64		Kaz Kojima
sparc		Anthony Green, Gordon Irlam
tile-gx/tilepro Walter Lee
vax		Miod Vallat
x86		Anthony Green, Jon Beniston
x86-64		Bo Thorsen
xtensa		Chris Zankel

Jesper Skov and Andrew Haley both did more than their fair share of stepping through the code and tracking down bugs.

Thanks also to Tom Tromey for bug fixes, documentation and configuration help.

Thanks to Jim Blandy, who provided some useful feedback on the libffi interface.

Andreas Tobler has done a tremendous amount of work on the testsuite.

Alex Oliva solved the executable page problem for SElinux.

The list above is almost certainly incomplete and inaccurate. I'm happy to make corrections or additions upon request.

If you have a problem, or have found a bug, please send a note to or to me directly (