我想在 Windows7 中使用 swig 使用 Go 中的 C++ 類當(dāng)我構(gòu)建項目“go build main.go”時,出現(xiàn)以下錯誤: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。當(dāng)我在 Windows7 中使用 64 位 Go 和 GCC 時,我看到同樣的錯誤。我能夠使用 64 位 go 和 gcc 在 Ubuntu 上成功構(gòu)建和運(yùn)行。我在 Windows 中遺漏了什么嗎?這是文件結(jié)構(gòu)和內(nèi)容。主(文件夾)main.gopackage mainimport ( "swtest")func main() { swtest.NewSwt().Print("Swig test!")}swtest(文件夾)測試文件#include "swtest.h"void Swt::Print(const std::string& s){ std::cout << s; std::cout << std::endl;}測試文件 #ifndef SWTEST_H #define SWTEST_H #include <string> #include <iostream> class Swt { public: void Print(const std::string& s); }; #endif swtest.go package swtestswtest.swigcxx%module swtest%include "std_string.i"%{#include "swtest.h"%}%include "swtest.h"
1 回答

手掌心
TA貢獻(xiàn)1942條經(jīng)驗 獲得超3個贊
請升級到 Go 1.5。這個問題在 Go 1.5 中得到解決。在以前的 Go 版本中,這是 Windows 操作系統(tǒng)中的已知問題。Go 團(tuán)隊已在 1.5 中修復(fù)。請查看以下線程,它將提供更多信息。
- 1 回答
- 0 關(guān)注
- 165 瀏覽
添加回答
舉報
0/150
提交
取消