Foreign Library Interface

We present an improved Foreign Function Interface (FFI) for R to call arbitary native functions without the need for C wrapper code. Further we discuss a dynamic linkage framework for binding standard C libraries to R across platforms using a universal type information format. The package rdyncall comprises the framework and an initial repository of cross-platform bindings for standard libraries such as (legacy and modern) OpenGL, the family of SDL libraries and Expat. The package enables system-level programming using the R language; sample applications are given in the article. We outline the underlying automation tool-chain that extracts cross-platform bindings from C headers, making the repository extendable and open for library developers.

Daniel Adler

CRAN packages used

rdyncall, Rffi

CRAN Task Views implied by cited packages


Text and figures are licensed under Creative Commons Attribution CC BY 4.0. The figures that have been reused from other sources don't fall under this license and can be recognized by a note in their caption: "Figure from ...".


For attribution, please cite this work as

Adler, "The R Journal: Foreign Library Interface", The R Journal, 2012

BibTeX citation

  author = {Adler, Daniel},
  title = {The R Journal: Foreign Library Interface},
  journal = {The R Journal},
  year = {2012},
  note = {},
  doi = {10.32614/RJ-2012-004},
  volume = {4},
  issue = {1},
  issn = {2073-4859},
  pages = {30-40}