How to use C++ code in Go: calling C++ functions and classes through C
Hello everyone! I've been writing in Go for about a year now, and I've encountered a task that has me stumped. I have a large C++ library that implements complex image processing logic. I want to use it in my Go project, but I don't know how to properly organize calling C++ functions from Go.\n\nI've read that Go can interact with C through cgo, but C++ is a completely different story. I tried writing a simple example: there is a C++ class ImageProcessor with a method process() that takes a byte array and returns a result. I created a C wrapper, but during linking I get "undefined reference" errors. Here's an example of my code:\n\n```go\npackage main\n\n/*\n#include "image_processor.h"\n*/\nimport "C"\nimport "fmt"\n\nfunc main() {\n data := []byte{1, 2, 3, 4, 5}\n resu
No answers yet.
Log in to leave an answer