Executive Summary

Executive Summary

SWIG is an interface compiler that connects programs written in C and C++ with scripting languages such as Perl, Python, Ruby, and Tcl. It works by taking the declarations found in C/C++ header files and using them to generate the wrapper code that scripting languages need to access the underlying C/C++ code. In addition, SWIG provides a variety of customization features that let you tailor the wrapping process to suit your application.

John Ousterhout (creator of Tcl) has written a paper that describes the benefits of scripting languages. SWIG makes it fairly easy to connect scripting languages with C/C++ code.

SWIG is used in a number of ways:

SWIG is sometimes compared to interface definition language (IDL) compilers such as those you find with systems such as CORBA and COM. Although there are a few similarities, the whole point of SWIG is to make it so you don't have to add an extra layer of IDL specifications to your application. If anything, it's much more of a rapid application development and prototyping tool. Specifically: Finally, it is worth noting that even though SWIG is occasionally compared to other more specialized scripting language extension building tools (e.g., Perl XS, Python bgen, etc.), its primary audience is C/C++ programmers who want to add a scripting language component to their applications. Because of this, SWIG tends to have a slightly different focus than tools designed to build small modules for widespread use in a scripting language distribution. applications.

A number of papers and tutorials describing SWIG are available. You can also view a simple tutorial to see an example of SWIG in action, or check out how other people are using SWIG in their projects.

SWIG has been freely available in various forms since February, 1996 and a large number of developers have made contributions. Today, SWIG remains an all-volunteer effort. Approximately 875 people subscribe to the swig mailing list and a public CVS repository is available at SourceForge. Versions of SWIG can now be found in most Linux distributions (however, you'll almost certainly want to get the latest version here).