Problem creating shared library with SWIG GO and C++ wrapper containing callbacks

Viewed 286

Does anyone ever had any issues when creating shared library (.dll), in the following scenario: SWIG go, C++ wrapper, and callback functions in C++? I noticed that the C++ wrapper generated by SWIG go will use extern “C” for the callbacks, eg:

.cxx:

extern “C” void Swiggo_DeleteDirector_Callback_5b45909afdbe1105(intgo);

.go:

//export Swiggo_DeleteDirector_Callback_5b45909afdbe1105
func Swiggo_DeleteDirector_Callback_5b45909afdbe1105(c int) {
    swigDirectorLookup(c).(*_swig_DirectorCallback).SwigcptrCallback = 0
    swigDirectorDelete(c)
}

The above will cause ‘undefined references’ error when I tried to call: gcc -shared file_wrap.cxx libfile.dll

Im using MingW64 in Windows.

My understanding is that SWIG Go is meant to link statically as it uses extern "C" when generating the cxx wrapper containing the callback functions. Is it possible to generate a shared library with SWIG go and cxx wrapper containing callback function?

Note: the above problem is specific to windows, as linux and mac can generate the sharedlibs (.so, .dylib) with callback functions successfully.

Thanks much...

0 Answers
Related