- Generate the bindings from the header in the interface file
swig -c++ -guile example.i
- Compile the wrapper code
g++ -fPIC -I/usr/include/guile/3.0 -c example_wrap.cxx
- Compile the implementation file
g++ -fPIC -c example.cpp
- Create the shared library from the wrapper object file and the implementation object file
g++ -shared example.o example_wrap.o -o libexample.so
This library can then be called from Guile, see the example.scm
file for an example of loading the library and calling the C++ code.
This is a simple example, for information about working with more advanced C++ features (e.g. overloaded functions/operators, templates etc) check out the official SWIG documentation.