swig
Generate language bindings for C/C++ code
TLDR
Generate Python wrapper
SYNOPSIS
swig [-python|-java|-ruby] [-c++] [-o file] [options] interface.i
DESCRIPTION
swig (Simplified Wrapper and Interface Generator) generates wrapper code that allows C and C++ libraries to be called from other programming languages. It reads interface definition files (.i) that describe which functions, classes, and types to expose, and produces the glue code needed for the target language.
Supported target languages include Python, Java, Ruby, Perl, PHP, Lua, Go, JavaScript, C#, and many others. SWIG handles automatic type conversion and data marshaling between C/C++ and the target language, including complex types, pointers, arrays, and object-oriented constructs like inheritance and templates.
Interface files use a syntax similar to C/C++ header files with additional SWIG directives for controlling the wrapping process. SWIG can also parse actual C/C++ header files directly for simpler cases.
PARAMETERS
-python
Python target.-java
Java target.-ruby
Ruby target.-c++
C++ mode.-o FILE
Output file.-I DIR
Include path.-module NAME
Module name.
CAVEATS
Learning curve for interface files. C/C++ knowledge needed. Build system integration.
HISTORY
SWIG (Simplified Wrapper and Interface Generator) was created by David Beazley for connecting C/C++ with scripting languages.
