Bindings of the r2 api for Valabind and friends
C C++ Vala Python C# Lua Other
Clone or download
Latest commit e55c4fb Jul 9, 2018
Failed to load latest commit information.
awk Minor r2awk fixes Nov 5, 2012
c Use pkgconfig instead of sdk for the C test Aug 18, 2017
csharp Add support for swig-csharp (requires updated valabind) Mar 31, 2015
ctypes add pub, dist and uninstall for ctypes (radare2-ctypes package) Dec 28, 2017
cxx Lot of build fixes for --as-needed and mingw32 Aug 10, 2012
dlang Several fixes for the Vala bindings Oct 29, 2014
gir Made r2-bindings work again (though, not tested) with valabind. Jun 29, 2012
go Fix checking GOENV env variable Aug 19, 2014
guile * More work for the bindings Nov 4, 2011
java fixed new jni lib name in Dec 31, 2013
jna Add JNA work-in-progress hand-made bindings Feb 12, 2014
libr more useful syntax error for lua plugin (#190) Jun 2, 2018
lua Many enhacements for the lua bindings Jun 25, 2013
luvit * Add initial luvit bindings for testing (sync) Mar 13, 2012
newlisp * Enhacements for rarun2 Oct 24, 2011
node-ffi Bump for nodejs bindings Mar 3, 2014
node-swig Bump rbp.vapi Jun 22, 2015
ocaml Fix OCaml bindings build Nov 24, 2017
perl Add c api code examples Feb 2, 2017
php5 Bump radare2-bindings renaming stuff Dec 20, 2013
python Fix ragdiff test Apr 3, 2016
r2rap/python Update Jul 5, 2016
ruby Update ruby tests Dec 20, 2013
vapi Release 2.7.0 Jul 9, 2018
.gitignore fix build of python bindings Jun 22, 2017
.travis.yml Install valabind as root in Travis Mar 5, 2018
COPYING Add license files Dec 21, 2013
COPYING.LESSER Add license files Dec 21, 2013
Makefile add pub, dist and uninstall for ctypes (radare2-ctypes package) Dec 28, 2017 Add experimental genbind script May 17, 2018
TODO * fix make clean in r2-bindings Jun 21, 2012 * Rename swig/ to r2-bindings May 17, 2011 Log check-langs issues in config.log May 31, 2016 Add cherrypull script Oct 3, 2015 Remove usercc configure flags to honor environment Aug 20, 2015
configure Release 2.7.0 Jul 9, 2018
configure-langs Change behaviour of check-langs and configure-langs with --enable Jul 31, 2014
configure.acr Release 2.7.0 Jul 9, 2018
configure.hook Fix lua bindings build Jul 16, 2013 Apply @ret2libc's patch fixing NodeJS bindings and use SDB namespace Dec 11, 2014 * Rename swig/ to r2-bindings May 17, 2011 genbind - better error reporting Jul 4, 2018 * Fix pkg-config-symstall May 20, 2011 Code cleanup in one ctypes example, ensure it works now Dec 28, 2017 * Fix bindings Dec 5, 2011
python-config-wrapper Honor PYVER in python-config-wrapper May 31, 2017
python-wrapper * Add 'python-wrapper' to use python2 in install-python target Jun 26, 2012 add pub, dist and uninstall for ctypes (radare2-ctypes package) Dec 28, 2017

radare2 language bindings for r2 api

This repository contains the native bindings generated with Valabind to use the radare2 APIs.

The r2pipe implementations has been moved into a separate repository.


This directory contains the code necessary to use the r2 api from your favourite language.

It supports a large list of programming languages:

  • Python, JavaScript, Java, Vala, Go, Ruby, Perl, Lua, NewLisp, Guile, OCaml

And some other experimental bindings are for:

  • GIR, C++, C#

This package also contains the vdoc/ subdirectory which contains the rules used to generate all interactive html documentation found at:


To build radare2-bindings from repository you need the following programs installed:

  • swig: enables support for python, perl, lua, java and many other
  • vala: if you want to have Vala or Genie bindings
  • valabind: required only in developer mode (not release tarball)

Release tarballs come with all the pregenerated .cxx files, so you have no extra dependencies apart from the language libraries and C++ compiler.

To get install all dependencies do the following steps in order:

  • Install swig and git from repository (ensure you don't have vala installed from package)

    arch$ sudo pacman -S swig git
    deb$ sudo apt install swig git
  • Install latest release of Vala from tarball

    ./configure --prefix=/usr
    sudo make install
  • Clone vala compiler from git repository:

    $ git clone git://
    $ cd vala
    $ sh --prefix=/usr
    $ make
    $ sudo make install
  • Fetch valabind from the repository:

    $ git clone git://
    $ cd valabind
    $ make
    $ sudo make install PREFIX=/usr

To keep bindings up-to-date

When changes are done in libr an ABI break can occur. The bindings will require to be recompiled to work again.

It's recommendable to keep your system always up to date, and upgrade vala and valabind from git/hg.

$ cd vala
$ git pull
$ make
$ sudo make install

$ cd ../valabind
$ git pull
$ make
$ sudo make install PREFIX=/usr


If you compile from the repo you need the latest version of valabind and then:

./configure --prefix=/usr

You can select the languages you want to compile with --enable={list-of-langs}

./configure --prefix=/usr --enable=python

Experimental radare2 bindgen


This script allows to generate native bindings for these languages directly from radare2 C headers:

More languages are planned, in particular:

  • Ruby - I wanted to use ffi-gen but it needs revival and update to the modern Ruby and Clang.
  • OCaml - needs to be written
  • Lua - maybe LuaAutoC can be used, I don't know.

Usage -o /tmp/r2bindings-output

The tool required radare2 to be installed and takes the include directory from the output of r2 -H


To select the version of python to compile for use the PYTHON_CONFIG environment variable as follows:

$ ./configure --prefix=/usr --enable-devel
$ cd python
$ PYTHON_CONFIG=python2.7-config make
$ su -
# PYTHON_CONFIG=python2.7-config make install


The valabind integration forces us to do some changes in the r2 API.

These api changes are for:

  • Avoid keywords in function names

    Every language has its own keywords, r2api should try to workaround all those keywords to avoid collisions for bindings.

    Example: use, del, from, continue, etc..

    TODO: we need to review APIs, find better names for functions using those keywords, etc..

  • Review basic data structures

    Linked lists, hash tables, r_db, arrays, ... must be reviewed to fit with vala and swig basics to be able to use them with simple APIs or integrate them with the syntax sugar of the target language.

    Example: foreach (var foo in binls.get_symbols ()) { print ("%s 0x%08"PFMT64x"\n",, foo.offset); }

  • Unit testing

    Having bindings for python, perl, ruby, .. is good for unit testing because it hardly simplifies the way to test APIs, find bugs, ...

    TODO: write unit testing frameworks for perl, ruby, python, etc..

  • API unification for all languages

    All the previous development points are meant to reduce code in r2, avoid syntax exceptions, simplify api usage, and much moar ;)

SWIG is not complete, there are still so many bugs to fix and so many unimplemented stuff. Here's a list of the most anoying things of it:

  • unsigned char * : not implemented