Skip to content

opensourcedoc/go-c-cpp-mix

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Using C++ Classes in Go

Go programs can interface with C libraries using cgo. However, cgo does not natively support C++ classes or functions. To work around this limitation, C++ code must be wrapped in a C-compatible interface.

This repository provides a minimal working example demonstrating how to:

  • Wrap a C++ class with a plain C interface
  • Compile and link the C++ code as a shared library
  • Call C++ class methods from Go using cgo through the C wrapper

This technique is useful when integrating Go applications with existing C++ codebases or leveraging C++ libraries in a Go environment.


License

Apache License 2.0 Copyright (c) 2019–2020, ByteBard

About

Using C++ Class in Golang

Topics

Resources

License

Stars

Watchers

Forks

Contributors 2

  •  
  •