1

I'm trying to compile the RakNet game networking C/C++ library for use in Go. I'm currently using swig -c++ -go -cgo -intgosize 64 build.swigxx && go build to convert the project into a Go interface, but I'm running into the following error:

build_wrap.cxx:886:56: error: variable or field '_wrap_RakNetworkFactory_set_gorak_aae8103e4a7c6905' declared void
 void _wrap_RakNetworkFactory_set_gorak_aae8103e4a7c6905(RAK_DLL_EXPORT *_swig_go_0) {
                                                        ^
build_wrap.cxx:886:73: error: '_swig_go_0' was not declared in this scope
 void _wrap_RakNetworkFactory_set_gorak_aae8103e4a7c6905(RAK_DLL_EXPORT *_swig_go_0) {
                                                                         ^
build_wrap.cxx:2366:1: error: expected '}' at end of input

As far as I can tell it doesn't like the RAK_DLL_EXPORT being defined as empty (#define RAK_DLL_EXPORT), but I definitely don't know enough about what I'm doing to know if that's the case.

This issue seems to be specifically happening to setters being created by swig, because if I remove the header file the above is happening, swig gives me more errors of a similar nature.

The only thing vaguely approximating what I'm trying to do is this, but it looks like they're using a profoundly different version of RakNet. A lot of the resources relating to swig, cgo, and compiling C++ into go seem to be pretty dated and I haven't found any of much use.

Can anybody who understands these technologies better than I do help me figure this out?

JonRB
  • 175
  • 6
  • Your declaration seems to be missing a parameter type that should have been inserted between the `RAK_DLL_EXPORT` macro and `*_swig_go_0`. – Konrad Rudolph Jan 21 '19 at 09:56
  • That line is generated by SWIG, the part of the codebase it comes from doesn't even have getters or setters. I could manually insert a type, but I don't even know what type should go there. I _think_ that `RAK_DLL_EXPORT` is supposed to contain the type or something? – JonRB Jan 21 '19 at 10:03
  • 1
    I’m aware, but I’m saying that it’s not generated correctly, and to solve your problem you need to find out why that is. `RAK_DLL_EXPORT` isn’t supposed to contain a type, it just contains a DLL export specification (which may be empty, as in your case). – Konrad Rudolph Jan 21 '19 at 10:05
  • Oh, right - Do you have any idea how to figure that out? – JonRB Jan 21 '19 at 10:48

0 Answers0