Introduction to SWIG

SWIG (Simplified Wrapper and Interface Generator) is a compiler that integrates C and C++ with languages including Perl, Python, Tcl, Ruby, PHP, Java, C#, D, Go, Lua, Octave, R, Scheme, Ocaml, Modula-3, Common Lisp, and Pike. SWIG can also export its parse tree into Lisp s-expressions and XML.

SWIG reads annotated C/C++ header files and creates wrapper code (glue code) in order to make the corresponding C/C++ libraries available to the listed languages, or to extend C/C++ programs with a scripting language.

This package is known to build and work properly using an LFS-7.5 platform.

Package Information

  • Download (HTTP): http://downloads.sourceforge.net/swig/swig-2.0.12.tar.gz

  • Download MD5 sum: c3fb0b2d710cc82ed0154b91e43085a4

  • Download size: 5.06 MB

  • Estimated disk space required: 70 MB (up to 1 GB for tests)

  • Estimated build time: 0.4 SBU (11 SBU for tests of Perl, Python, Lua, Ruby, Guile, tcl, and PHP)

SWIG Dependencies




Boost-1.55.0 for tests, and any of the languages mentionned in the introduction, as run-time dependencies

User Notes: http://wiki.linuxfromscratch.org/blfs/wiki/swig

Installation of SWIG

Install SWIG by running the following commands:

./configure --prefix=/usr &&

To test the results, issue: make -k check. According to SWIG's documentation, the failure of some tests should not be considered harmful.

Now, as the root user:

make install &&
install -v -m755 -d /usr/share/doc/swig-2.0.12 &&
cp -v -R Doc/* /usr/share/doc/swig-2.0.12

Command Explanations

--without-<language>: allows disabling the building of tests and examples for <language>, but all the languages capabilities of SWIG are always built.


Installed Programs: swig and ccache-swig
Installed Library: None
Installed Directories: /usr/share/swig/2.0.12 and /usr/share/doc/swig-2.0.12

Short Descriptions


takes an interface file containing C/C++ declarations and SWIG special instructions, and generates the corresponding wrapper code needed to build extension modules.


is a compiler cache, which speeds up re-compilation of C/C++/SWIG code.

Last updated on 2014-02-20 06:45:35 -0800