This repo is an example of bindings created via SWIG between C++ example
- swig to generate language bindings (http://www.swig.org/svn.html)
- goloang for running the shared library
- c++ compiler for creating the shared libraried (use
g++
)
swig -go -cgo -c++ -intgosize 64 -outdir gocpp gocpp/gocpp.i
Updates gocpp/gocpp.go
and gocpp/gocpp_wrap.cxx
.
This needs to be done every time the code for gocpp.cpp
and gocpp.h
changes.
Works for both MacOS and Linux.
cd gocpp
g++ -std=c++11 -fPIC -c gocpp.cpp gocpp_wrap.cxx
cd ../
Works for both MacOS and Linux.
g++ -shared -o gocpp/_gocpp.so gocpp/gocpp.o gocpp/gocpp_wrap.o
go test -v
Two Options:
- 1.) You can run the
gen_lib
file locally and everything will be built - 2.) Run
docker-compose up -d --build
- Creates a container that builds all the bindings, creates the c++ binary and creates the library file
- Creates another container once the build one finishes that runs the tests