wangkuiyi / go-cpp

This project demonstrates how to let Go programs invoke statically linked C++ libraries without using SWIG.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Go-Cpp

This project demonstrates how to call C++ code from Go program without the need of using SWIG.

The basic idea is to write a C wrapper of C++ code, and use cgo to call this C wrapper.

Checkout and Build

git clone -b develop https://github.com/wangkuiyi/go-cpp
cd go-cpp/c++
scons
cd ../go
export GOPATH=`pwd`
cd src/go_prog
go install
DYLD_LIBRARY_PATH=$GOPATH/../c++/ $GOPATH/bin/go_prog

Note that you need to install SCons to build the C++ part. In order to install SCons on Mac OS X, you can use Homebrew.

If you are using Linux, the last command to run the demo program is:

LD_LIBRARY_PATH=$GOPATH/../c++/ $GOPATH/bin/go_prog

About

This project demonstrates how to let Go programs invoke statically linked C++ libraries without using SWIG.


Languages

Language:C++ 45.1%Language:Go 28.5%Language:C 17.1%Language:Python 9.3%