Open-source project
swig/swig avatar
swig/swig

SWIG: the header-to-glue compiler that lives or dies by swig.swg

SWIG is a software development tool that connects programs written in C and C++ with a variety of high-level programming languages.

6,336 stars1,317 forksSWIGNOASSERTION

At a glance

What is it?
SWIG reads annotated C and C++ headers and writes wrapper code for fifteen named languages, or exports its parse tree as XML. Its own text is candid about the boundary: it generates source, then hands the rest of the build to you.
Who is it for?
Pick SWIG when one C or C++ library has to be reachable from several languages and you are willing to own every build step around the file it writes. Do not expect a hosted release, a pinned version, or test coverage beyond the hardware the maintainers name.
Can I use it commercially?
Check first. The repository uses a licence we do not classify automatically, so read its LICENSE file before any commercial use.
Is it still maintained?
Yes. The repository last received commits 4 days ago.
What is it written in?
Mainly SWIG, according to GitHub's language statistics.

Answers come from the project's GitHub data, last synced on November 15, 2026, and from our analysis. They are not legal advice.

From daily snapshots

Star history

  • swig/swig6,336 ★ · +12
Star history
Repository2026-09-232026-11-15
swig/swig6.3k6.3k

12 Stars in the last 53 days, measured from the daily GitHub snapshot. Compare with other projects

Editorial analysis

Annotated C/C++ headers are the input, wrapper code is the output

Calling SWIG a binding generator undersells the shape of it. The project calls itself a compiler that integrates C and C++ with languages including Perl, Python, Tcl, Ruby, PHP, Java, C#, D, Go, Lua, Octave, R, Scheme (Guile), Scilab, and Ocaml. The input is not a script but your header files with SWIG annotations added, and the output is wrapper code, called glue code in the project text, that you then compile against your library. The same front end can also export its parse tree into XML, which is the only alternative output format the project mentions. Two directions are named: making an existing C or C++ library available to one of those languages, and extending an existing C or C++ program with a scripting language. Notice what is absent. Nothing here describes a runtime bridge living inside SWIG. The generator writes files, and the compiled program does the rest. That boundary is where every practical surprise lives.

swig.swg and tcl8.swg: the two files that decide whether SWIG runs

Before it parses anything, SWIG has to find its own library files, and the documented failure mode is two error lines rather than a crash on your header.

code
$ swig foo.i
:1. Unable to find 'swig.swg'
:3. Unable to find 'tcl8.swg'

Look closely at what is missing: no complaint about foo.i, no syntax error, no mention of a line in your own code. Recovery is given as a numbered ladder: confirm that make install actually ran and that you had write permission on the install directory, then type swig -swiglib to ask the binary where it believes its library sits, and if that path is not the one you expected, redo the configure step with ./configure --prefix=pathname instead of guessing. There is also a warning against putting a shell escape character such as ~ in the prefix, which is a quiet way to produce a path that does not exist. SWIG_LIB overrides the location outright, and the project says you really should not have to use it.

A release tarball and a GitHub clone are two different installations

Two install paths are documented and they are not interchangeable. The release tarball or zip file has full instructions in Doc/Manual/Preface.html#Preface_installation for Windows, Unix and Mac OS X, while the INSTALL file carries generic build and installation instructions for Unix users. A clone from GitHub needs extra steps that live on a separate page, https://swig.org/svn.html, and that difference is worth knowing before you decide to build from the repository. The test step named for Unix systems is make -k check, with its details in Doc/Manual/Preface.html#Preface_testing. A first pass assembled only from files and commands the repository actually carries looks like this:

code
Doc/Manual/Preface.html#Preface_installation
Doc/Manual/Preface.html#Preface_testing
Doc/Manual/SWIGDocumentation.pdf
INSTALL
make -k check
swig foo.i

After make install, swig foo.i is the smallest end to end check available. It is the same command the troubleshooting section uses when the library files go missing, so it walks the path your real invocation will walk. If it prints those two Unable to find lines, the fault is the install prefix and nothing in your interface file.

SWIG_VERSION is the only handle on compatibility in generated code

Backward compatibility is a stated goal that is explicitly not a promise. The position is that the developers strive their best to preserve it between releases but that this is not always possible, because the overriding aim is to provide the best wrapping experience. What that means in practice is bounded by where breaks are recorded: known incompatibilities are marked as such in the CHANGES and CHANGES.current files, so you can find them without reading generated code. For a team sitting on the other side of that boundary, the documented mechanism for running more than one version at a time is the SWIG_VERSION preprocessor symbol, which the documentation points you to when you have compatibility issues. There is nothing else. The repository tree carries no lockfile, no pinned version file, and no rollback procedure, and no GitHub releases are published either, so the changelog files and that one preprocessor symbol are the entire version story available to a new user.

Doc/Devel holds the internals notes and disclaims itself

Three copies of the manual ship inside Doc/Manual with identical content: a PDF at Doc/Manual/SWIGDocumentation.pdf, a single page HTML file at Doc/Manual/SWIGDocumentation.html, and the remaining multi page HTML files in the same directory. The instruction is to pick your format and copy or install it wherever you like. A second directory, Doc/Devel, carries developer documentation about SWIG internals, and the README attaches a warning to it directly: this is not necessarily up to date. That sentence matters if you are reaching for internals precisely because a generated wrapper misbehaves, because the one document aimed at that situation is the one the project declines to vouch for. The maintained paths are the wiki at https://github.com/swig/swig/wiki, described as the home of the SWIG FAQ and other hints, and the online copy at https://www.swig.org/doc.html. Known bugs go to https://www.swig.org/bugs.html.

Examples/ has a directory per target, and two are outside the tagline

The Examples directory is laid out one folder per target: android, c, csharp, d, go, guile, java, javascript, lua, ocaml, octave, perl5, php, python, r, ruby, scilab, tcl, plus test-suite, a Makefile.in, a README, and an index.html you point a browser at. Two entries deserve a second look against the headline list. The tagline names fifteen languages and says nothing about JavaScript or Android, yet Examples/javascript and Examples/android both exist in the tree. What the tree confirms is that example code exists for those targets. It does not settle how complete or how current those bindings are, and nothing in the project text grades them. The Windows side of the same directory is dated as well: the included project files are Visual C++ 6 .dsp files, and the README notes that later versions of Visual Studio will convert those old style files into a current solution file. Any plan to build examples on Windows inherits that conversion step.

Where the run ends: nothing in the tree compiles your wrapper

Read the scope statement literally. SWIG reads annotated headers and creates wrapper code. The README does not describe compiling that code, linking it to your library, installing the result as a module, or loading it at runtime. Those steps belong to your language's own toolchain. The library lookup has an edge worth naming too: swig -swiglib answers the question per machine, so a prefix baked in at configure time travels with the build and can differ between your laptop and a CI container. SWIG_LIB exists for that case and is discouraged. The bug tracker is described as holding minor known bugs, which is a small promise, and no part of the text enumerates what happens on a large real header set. For the cases it does not cover, the project points at the wiki and at the swig-devel mailing list at https://www.swig.org/mail.html.

Fresh commits, no releases: dating what you cloned

The last push to the default branch, master, landed on 2026-10-28, so the tree moves. The repository publishes no GitHub releases, which means no tag, no attached tarball, and no rendered release page to tell you which build you are holding. Version detail lives in three files instead: CHANGES.current for bug fixes and new features in the current release, CHANGES for older versions, and RELEASENOTES for a summary per release. Anyone pinning SWIG for a build reads those files rather than comparing numbers on a hosting page. The build system shows the same dual life, with CMakeLists.txt sitting beside configure.ac, autogen.sh, Makefile.in, preinst-swig.in and a CCache directory, and AGENTS.md, .github/, .agents/ and .claude/ alongside them. The project is also candid about its own test reach: the README says the maintainers have access to a limited variety of hardware, Linux, Solaris, OS-X and Windows, and that all contributions help.

Editorial conclusion

Pick SWIG when one C or C++ library has to be reachable from several languages and you are willing to own every build step around the file it writes. Do not expect a hosted release, a pinned version, or test coverage beyond the hardware the maintainers name. Before committing, run swig -swiglib on the machine that will compile the wrapper, read CHANGES.current for the marked incompatibilities, and open the example directory for your own language to see how much is there.

Frequently asked questions

What does "swig" mean in slang?

The project expands the name as Simplified Wrapper and Interface Generator, a compiler that turns annotated C and C++ headers into wrapper code. The repository text defines the name only that way and does not trace the word's use as slang.

What does "swig" mean?

In this project it stands for Simplified Wrapper and Interface Generator. It reads annotated C or C++ header files and writes glue code so a library can be called from Perl, Python, Tcl, Ruby, PHP, Java, C#, D, Go, Lua, Octave, R, Scheme (Guile), Scilab and Ocaml.

How did SWIG get popular?

The project text records no adoption history. What it offers instead is a change trail: CHANGES.current for the current release, CHANGES for older versions, RELEASENOTES for a summary of each release, and a wiki for background and hints.

What is Python SWIG?

It is the Python binding that SWIG generates from annotated C or C++ headers: glue code you compile against the library and import from Python. The repository ships a Python example directory under Examples, and the README troubleshooting section shows SWIG failing with Unable to find errors when its library files are not installed correctly.

Official sources

  1. Issues
  2. Project website
  3. README
  4. swig/swig on GitHub
Add this badge to your README

If you maintain this project, the badge below links readers to this analysis and shows its maintenance status from the daily GitHub snapshot. Paste the markdown into your README; add ?metric=license or ?metric=stars to the image URL for a different field.

Add this badge to your README

markdown
[![Hysen Labs](https://hysenlabs.com/badge/swig-swig.svg)](https://hysenlabs.com/projects/swig-swig)

Star history chart for your README

markdown
[![Star history](https://hysenlabs.com/chart/swig-swig.svg)](https://hysenlabs.com/projects/swig-swig)

Was this useful?