【发布时间】:2016-01-07 19:15:53
【问题描述】:
我想在 Windows7 中使用 swig 使用 Go 中的 C++ 类
当我构建项目“go build main.go”时,出现以下错误:
c:\..\Temp\go-build591352403/swtest.a(swtest_wrap.o):格式错误的 pe 文件:__cgo_topofstack:无效符号绑定 105
我在 Windows7 中使用 go 1.3 32bit、gcc 4.8.1 32bit 和 swig 3.0。 当我在 Windows7 中使用 64 位 Go 和 GCC 时,我看到了同样的错误。
我能够使用 64 位 go 和 gcc 在 Ubuntu 上成功构建和运行。
我在 Windows 中遗漏了什么吗?
这是文件结构和内容。
主(文件夹)
-
main.go
package main import ( "swtest" ) func main() { swtest.NewSwt().Print("Swig test!") }
swtest(文件夹)
-
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"
【问题讨论】: