2

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.

metaleap
  • 2,132
  • 2
  • 22
  • 40

1 Answers1

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

Vincenzo Maggio
  • 3,787
  • 26
  • 42
  • Just a note: there is no "runtime infamous memory leak", Go has a conservative garbage collector that *in 32bit systems under some rare circumstances* means garbage doesn't get collected. Nobody has reported any problems with 64bit systems, which anyway is much faster and has been tested much more. tl;dr: Stick to Go under 64bit and you should have nothing to worry about. – uriel Apr 28 '12 at 12:50
  • Yeah there are 3 patch-sets that when applied to Go 1.0.1 resolve the issue: http://groups.google.com/group/golang-nuts/browse_thread/thread/b98c3677ec716379 ... I'm still having issues with building go-glfw though, but that's a different matter... so marking this as Answer. – metaleap Apr 29 '12 at 02:58
  • Just in case anyone is interested in my very peculiar glfw-only cgo issue... http://stackoverflow.com/questions/10369513/dll-linking-via-windows-cgo-gcc-ld-freeglut-works-glfw-doesnt-whats-the-c – metaleap Apr 29 '12 at 04:27