[英]Using C++ classes from Go using Swig
我想在Windows7中使用Swig中的C ++類
當我構建項目“go build main.go”時,我收到以下錯誤:
c:\\ .. \\ Temp \\ go-build591352403 / swtest.a(swtest_wrap.o):格式錯誤的pe文件:__ cgo_topofstack:無效的符號綁定105
我在Windows7中使用的是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"
如果你感覺大膽,那么Windows的pe錯誤在Go 1.5beta1中得到修復。 給它一個旋轉! 下載1.5 beta2
請升級到Go 1.5。 在Go 1.5中解決了這個問題。 在之前的Go版本中,Windows OS中存在已知問題。 Go團隊已經固定在1.5。 請查看以下主題,它將提供更多信息。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.