|
From: Jirka D. <jir...@gm...> - 2013-08-02 17:01:49
|
Hello, I posted this problem to golang-nuts mailing list, but during the week it received zero attention.there, so I am reposting it here. I have a minimal example that exhibits the error and also a workaround: manually comment some offending lines in _wrap.h file. Thanks for any help. My original post: If i git clone the following test program and compile it (I do it manually, without using go build magic), I get a linker error because the SWIG generated code somehow ends up wanting to call a pure virtual method that obviously has no symbol in object files. Am i doing something wrong, or is it a bug? https://gist.github.com/jirkadanek/6108231 git clone https://gist.github.com/6108231.git cd 6108231 swig -c++ -go -gccgo -intgosize 64 -v -Wall gowork.i g++ -c gowork_wrap.cxx g++ -c work.cc mkdir gowork mv gowork.go gowork/ gccgo -c gowork/gowork.go gccgo -c gomain.go gccgo gomain.o gowork.o gowork_wrap.o work.o -o gomain -lstdc++ * last command fails with [jirka@localhost Work]$ gccgo gomain.o gowork.o gowork_wrap.o work.o -o gomain -lstdc++ gowork_wrap.o: In function `SwigDirector_Observer::_swig_upcall_OnSuccess()': gowork_wrap.cxx:(.text._ZN21SwigDirector_Observer22_swig_upcall_OnSuccessEv[_ZN21SwigDirector_Observer22_swig_upcall_OnSuccessEv]+0x14): undefined reference to `Observer::OnSuccess()' collect2: error: ld returned 1 exit status * edit gowork_wrap.h, comment line in method _swig_upcall_OnSuccess that tries to call Observer::OnSuccess() * recompile gowork_wrap.cxx * now links fine * run with ./gomain (the main.cc file is there just for testing, it does what gomain.go does) BTW, what is the purpose of the upcall methods? It seems to me that it tries to call the superclass methods, but I always believed that is just a convention in some frameworks and you do not have to do it _always_. Or maybe it gets actually executed only for methods that I don't override in my director class... BBTW; Is this a good place to ask any other SWIG-Go questions, I have one more problem with std::string* that I again can work around, but would like to know some correct solution or best practice... |