SWIG

SWIG is a software development tool that connects programs written in C and C++ with a variety of high-level programming languages. SWIG is used with different types of target languages including common scripting languages such as Javascript, Perl, PHP, Python, Tcl and Ruby.

% swig -go example.i
% gcc -fpic -c example.c example_wrap.c -I /usr/local/include
% gcc -shared example.o example_wrap.o -o example.so

SWIG and Go

How to interface SWIG and Go is explained in the SWIG documentation. Go usually interfaces to C using cgo, but cannot easily interface to C++. This is where SWIG can help. For more information, see the documentation.