Skip to content

A simple example showcasing how to generate and use bindings for a (simple) C++ class in Guile using SWIG

Notifications You must be signed in to change notification settings

jw-0/GuileSwigCppExample

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Example SWIG binding generation for C++ code in Guile

  1. Generate the bindings from the header in the interface file

swig -c++ -guile example.i

  1. Compile the wrapper code

g++ -fPIC -I/usr/include/guile/3.0 -c example_wrap.cxx

  1. Compile the implementation file

g++ -fPIC -c example.cpp

  1. 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.

About

A simple example showcasing how to generate and use bindings for a (simple) C++ class in Guile using SWIG

Resources

Stars

Watchers

Forks