Windows DLL链接与cgo

huangapple go评论100阅读模式
英文:

Windows DLL-linking with cgo

问题

我的终极目标是成功地从Go包中链接到一些DLL(opengl32.dll glfw.dll和glu32.dll)- 但是尝试链接到go-glfw包给了我“未定义”错误

所以我决定让一个非常简单的cgo动态/共享库链接工作,使用%GOROOT%\misc\cgo\life中的简单未修改的示例。但是只是调用命令go build -o life main.go失败,基本上是相同的链接器错误,即:

go-build374967034/_/C_/Go/misc/cgo/life.a(c-life.o)(.text): _assert: not defined

“未定义”...就是我尝试链接glfw时遇到的完全相同的错误。

这是一个全新的未经修改的Go 1.0.1安装,今天早上刚刚下载的,安装在一个原始的、相当新的Win7 64位安装上。可能出了什么问题?我知道...Windows。很想听听任何想法...从我在网上读到的东西来看,似乎使用CGO进行DLL链接是一件轻而易举的事情。然而,即使是最简单的示例也无法正常工作。

英文:

My ultimate goal is to successfully link to a number of DLLs (opengl32.dll glfw.dll and glu32.dll) from a Go package -- but trying to link to the go-glfw package gave me "not defined" errors.

So I decided to get a very simple cgo dynamic/shared library linking to work, from the simple unmodified example in %GOROOT%\misc\cgo\life. But just invoking the command go build -o life main.go fails with essentially the same linker error, namely:

go-build374967034/_/C_/Go/misc/cgo/life.a(c-life.o)(.text): _assert: not defined

"not defined"... just exactly the same error I had when trying to link glfw as per above.

This is a fresh untampered-with install of Go 1.0.1 freshly downloaded this morning, on a vanilla, fairly recent Win7 64-bit installation. What could possibly go wrong? I know... Windows. Would love to hear any ideas... seems like DLL linking with CGO is a no-brainer and simple to do from what I read around the net. Yet even the simplest of examples fails for me.

答案1

得分: 1

我认为这个特定的错误已经在这里讨论过:http://code.google.com/p/go/issues/detail?id=3261,但我不确定它是否适用于你的情况。根据我所读到的,最后他们提出了一个修补程序,但我没有真正尝试过,因为我正在等待1.1版本的发布(希望他们能修复运行时的臭名昭著的内存泄漏问题;))

英文:

I've think this particular bug has been discussed here: http://code.google.com/p/go/issues/detail?id=3261
but I'm not sure if it can be applied to your case. In the end from what I've read they proposed a patching but not really tried 'cause I'm waiting 1.1 release (hoping they'll fix the runtime infamous memory leak Windows DLL链接与cgo )

huangapple
  • 本文由 发表于 2012年4月27日 15:46:00
  • 转载请务必保留本文链接:https://go.coder-hub.com/10346748.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定