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.6 platform.

Package Information

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

  • Download MD5 sum: 62f9b0d010cef36a13a010dc530d0d41

  • Download size: 5.42 MB

  • Estimated disk space required: 77 MB (up to 1.1 GB for tests)

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

SWIG Dependencies




Boost-1.56.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-3.0.2 &&
cp -v -R Doc/* /usr/share/doc/swig-3.0.2

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/3.0.2 and /usr/share/doc/swig-3.0.2

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-09-21 01:03:52 -0700