Skip to content
/ go-cpp Public
forked from wangkuiyi/go-cpp

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

Notifications You must be signed in to change notification settings

kicool/go-cpp

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 

Repository files navigation

Go-Cpp

This project demonstrates how to make Go programs call C++ facilities.

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

However, it is known that C programs cannot call C++ facilities. The trick is to write the wrapper in C++, so it can contain some C functions defined using extern "C"; and exports only these C functions to cgo.

It is also notable that cgo allows Go programs to call C functions in shared libraries only. So we need to build the wrapper as a shared library. To do so, we build the C++ facilities into a static library, which is then linked into the wrapper (shared) library.

In this example project, we use SCons to build C++ code.

About

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

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published