dongyiluan1718 2012-04-27 07:46
浏览 228
已采纳

Windows DLL与CGO链接

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条回答 默认 最新

  • douce1368 2012-04-27 15:19
    关注

    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 ;) )

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 使用C#,asp.net读取Excel文件并保存到Oracle数据库
  • ¥15 C# datagridview 单元格显示进度及值
  • ¥15 thinkphp6配合social login单点登录问题
  • ¥15 HFSS 中的 H 场图与 MATLAB 中绘制的 B1 场 部分对应不上
  • ¥15 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配