A portable foreign-function interface library that enables calling compiled code from interpreters and other languages at runtime.
libffi is a portable foreign-function interface library that provides a low-level abstraction of calling conventions across different CPU architectures and operating systems. It enables programs like interpreters and dynamic code generators to call compiled functions at runtime without knowing the function signatures at compile time. The library serves as the foundational layer for building language interoperability systems.
Developers building language interpreters, JIT compilers, dynamic code generation systems, or any software that needs to interface between different programming languages or call compiled code dynamically. It's particularly valuable for implementers of scripting languages and runtime environments.
libffi offers unparalleled portability across hardware architectures and operating systems, with decades of refinement ensuring correctness. It provides a stable, battle-tested foundation for FFI implementations that would be extremely complex to develop from scratch, saving developers from dealing with architecture-specific calling convention details.
A portable foreign-function interface library.
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Supports dozens of CPU architectures and operating systems, from x86 and ARM to exotic platforms like VAX and WASM, as shown in the extensive platform table.
Enables calling functions with arguments determined at runtime, which is essential for interpreters and JIT compilers, as described in the 'What is libffi?' section.
Allows creating callable function pointers from interpreter callbacks, facilitating two-way communication between languages, a key feature highlighted in the overview.
Decades of development and refinement, used as the base for many language FFI systems, with a stable release history and continuous updates like the recent 3.5.2.
Only handles calling conventions; type conversions, memory management, and language integrations must be built on top, as admitted in the philosophy that it's the 'lowest layer'.
Building from git requires autoconf, automake, libtool, and texinfo, and Windows builds need wrapper scripts like msvcc.sh, making setup cumbersome for some environments.
The low-level API demands deep understanding of C ABIs and memory layouts, with minimal documentation beyond technical details, which can deter newcomers.