I want to use C++ class from Go using swig in Windows7
When I build the project "go build main.go" I am getting following error:
c:\..\Temp\go-build591352403/swtest.a(swtest_wrap.o): malformed pe file: __cgo_topofstack: invalid symbol binding 105
I am using go 1.3 32bit, gcc 4.8.1 32bit and swig 3.0 in Windows7. I see same error when I use 64bit Go and GCC in Windows7.
I am able build and run successfully on Ubuntu with 64-bit go and gcc.
Am I missing something in windows?
Here is the file structure and content.
main (folder)
-
main.go
package main import ( "swtest" ) func main() { swtest.NewSwt().Print("Swig test!") }
swtest (folder)
-
swtest.cpp
#include "swtest.h" void Swt::Print(const std::string& s) { std::cout << s; std::cout << std::endl; }
-
swtest.h
#ifndef SWTEST_H #define SWTEST_H #include <string> #include <iostream> class Swt { public: void Print(const std::string& s); }; #endif
-
swtest.go
package swtest
-
swtest.swigcxx
%module swtest %include "std_string.i" %{ #include "swtest.h" %} %include "swtest.h"