https://github.com/cwchentw/go-c-cpp-mix
Using C++ Class in Golang
https://github.com/cwchentw/go-c-cpp-mix
cgo cpp golang-examples
Last synced: 8 months ago
JSON representation
Using C++ Class in Golang
- Host: GitHub
- URL: https://github.com/cwchentw/go-c-cpp-mix
- Owner: opensourcedoc
- License: other
- Created: 2016-04-17T15:39:29.000Z (almost 10 years ago)
- Default Branch: master
- Last Pushed: 2025-06-08T10:49:15.000Z (10 months ago)
- Last Synced: 2025-06-21T01:37:49.516Z (10 months ago)
- Topics: cgo, cpp, golang-examples
- Language: C++
- Homepage:
- Size: 9.77 KB
- Stars: 9
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# 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