I am trying to make CGO link my C++ static library with GO code. I have written a C-wrapper header and c-source file with extern "C" calls like this
#ifdef __cplusplus
extern "C" {
#endif
and have added -stdc++
to the LDFLAGS
in my .go file
// #cgo CXXFLAGS: -std=c++14 -I. -flto
// #cgo LDFLAGS: -lstdc++ -L. -llibforgo
// #include "Wrapper.h"
import "C"
but the linker does not seem to find c++ standard calls ans is full of errors like
undefined reference to `operator new(unsigned long)'
undefined reference to `operator delete(void*, unsigned long)'
Here are related go environment variables
CC="gcc"
CXX="g++"
What I am doing wrong? How to tell cgo to use g++ instead of gcc? Maybe I should recompile
my static c++
library with some additional options?