I feel confusing about c++ wrapping.
It’s easy to bind with c code like this:
go file:
/*
// go preamble
#cgo pkg-config: mxnet
#include <mxnet/c_predict_api.h>
#include <stdlib.h>
*/
import "C"
pkg-config file:
prefix=/root/MXNet/mxnet
libdir=${prefix}/lib/
includedir=${prefix}/include
Name: mxnet
Description: custom pc file
Version: x.x.x
URL: https://github.com/dmlc/mxnet
Libs: -L${libdir} -lmxnet
Libs.private: -L${libdir} -lmxnet
Cflags: -I${includedir}
BUT it’s not work for c++ headers, c_api.h is written by c++
/*
// go preamble
#cgo pkg-config: mxnet
#include <mxnet/c_api.h>
#include <stdlib.h>
*/
import "C"
So i have few questions to ask.
How to bind c++ code when i have c++ headers and src files?
How to bind c++ code when i have c++ headers and library(*.a) files?
What will *go build .go do if i put #cgo CXXFLAGS: -std=c++11 in preamble section?
The cgo tool does not support C++.
The #cgo CXXFLAGS directive provides flags that are used to compile C++ files in the same directory
I heard this from a go collaborator , but getting more confused.
cgo does not support c++, but could build c++? Who will compile c++ code? g++ compiler or cgo?