swig

Generate bindings between C/C++ code and various high level languages such as JavaScript, Python, C#, and more. It uses special .i or .swg files to generate the bindings (C/C++ with SWIG directives, then outputs a C/C++ file that contains all the wrapper code needed to build an extension module. More information: <http://www.swig.org>.

Install

All systems
curl cmd.cat/swig.sh
Debian Debian
apt-get install swig
Ubuntu
apt-get install swig
Alpine
apk add swig
Arch Arch Linux
pacman -S swig
image/svg+xml Kali Linux
apt-get install swig
CentOS
yum install swig
Fedora
dnf install swig
Windows (WSL2)
sudo apt-get update sudo apt-get install swig
OS X
brew install swig
Raspbian
apt-get install swig
Docker
docker run cmd.cat/swig swig powered by Commando

Generate bindings between C/C++ code and various high level languages such as JavaScript, Python, C#, and more. It uses special .i or .swg files to generate the bindings (C/C++ with SWIG directives, then outputs a C/C++ file that contains all the wrapper code needed to build an extension module. More information: <http://www.swig.org>.

  • Generate a binding between C++ and Python:
    swig -c++ -python -o path/to/output_wrapper.cpp path/to/swig_file.i
  • Generate a binding between C++ and Go:
    swig -go -cgo -intgosize 64 -c++ path/to/swig_file.i
  • Generate a binding between C and Java:
    swig -java path/to/swig_file.i
  • Generate a binding between C and Ruby and prefix the Ruby module with `foo::bar::`:
    swig -ruby -prefix "foo::bar::" path/to/swig_file.i

© tl;dr; authors and contributors