go-gl-legacy / glfw

Go bindings for libglfw 2.x
http://www.glfw.org
BSD 3-Clause "New" or "Revised" License
73 stars 8 forks source link

Static library glfw.a - functions not defined #8

Closed fastpars closed 12 years ago

fastpars commented 12 years ago

Hi. I have trouble with glfw.a. Maybe it's the same bug like https://github.com/jteeuwen/glfw/issues/1 then sorry. How i can fix it?

Go1
Linux 3.0.0-17-generic #30-Ubuntu x86_64 GNU/Linux
glfw-2.7.5
$ sudo make x11-dist-install
...
install -c -m 644 libglfw.a /usr/local/lib/libglfw.a
...
$ sudo ldconfig -v | grep glfw
    libglfw.so -> libglfw.so
$ go run main.go
# command-line-arguments
go/pkg/linux_amd64/github.com/jteeuwen/glfw.a(glfw.cgo2.o)(.text): glfwGetTime: not defined
go/pkg/linux_amd64/github.com/jteeuwen/glfw.a(glfw.cgo2.o)(.text): glfwGetNumberOfProcessors: not defined
go/pkg/linux_amd64/github.com/jteeuwen/glfw.a(glfw.cgo2.o)(.text): glfwGetKey: not defined
go/pkg/linux_amd64/github.com/jteeuwen/glfw.a(glfw.cgo2.o)(.text): glfwSetTime: not defined
go/pkg/linux_amd64/github.com/jteeuwen/glfw.a(glfw.cgo2.o)(.text): glfwExtensionSupported: not defined
go/pkg/linux_amd64/github.com/jteeuwen/glfw.a(glfw.cgo2.o)(.text): glfwPollEvents: not defined
go/pkg/linux_amd64/github.com/jteeuwen/glfw.a(glfw.cgo2.o)(.text): glfwGetMousePos: not defined
go/pkg/linux_amd64/github.com/jteeuwen/glfw.a(glfw.cgo2.o)(.text): glfwGetJoystickParam: not defined
go/pkg/linux_amd64/github.com/jteeuwen/glfw.a(glfw.cgo2.o)(.text): glfwGetProcAddress: not defined
go/pkg/linux_amd64/github.com/jteeuwen/glfw.a(glfw.cgo2.o)(.text): glfwGetGLVersion: not defined
go/pkg/linux_amd64/github.com/jteeuwen/glfw.a(glfw.cgo2.o)(.text): glfwSetMouseWheel: not defined
go/pkg/linux_amd64/github.com/jteeuwen/glfw.a(glfw.cgo2.o)(.text): glfwGetJoystickPos: not defined
go/pkg/linux_amd64/github.com/jteeuwen/glfw.a(glfw.cgo2.o)(.text): glfwOpenWindow: not defined
go/pkg/linux_amd64/github.com/jteeuwen/glfw.a(glfw.cgo2.o)(.text): glfwSetMousePos: not defined
go/pkg/linux_amd64/github.com/jteeuwen/glfw.a(glfw.cgo2.o)(.text): glfwSwapInterval: not defined
go/pkg/linux_amd64/github.com/jteeuwen/glfw.a(glfw.cgo2.o)(.text): glfwGetMouseButton: not defined
go/pkg/linux_amd64/github.com/jteeuwen/glfw.a(glfw.cgo2.o)(.text): glfwSetWindowTitle: not defined
go/pkg/linux_amd64/github.com/jteeuwen/glfw.a(glfw.cgo2.o)(.text): glfwGetVideoModes: not defined
go/pkg/linux_amd64/github.com/jteeuwen/glfw.a(glfw.cgo2.o)(.text): glfwGetJoystickButtons: not defined
go/pkg/linux_amd64/github.com/jteeuwen/glfw.a(glfw.cgo2.o)(.text): glfwRestoreWindow: not defined
go/pkg/linux_amd64/github.com/jteeuwen/glfw.a(glfw.cgo2.o)(.text): glfwInit: not defined
too many errors
ghost commented 12 years ago

I am guessing this would similar to issue #1.

Considering the lib works for everyone else (at least as far as I know), I can only guess that there is a problem with the linker finding the lib on your system. I had a similar issue at some point. This was because libglfw installed itself to /usr/local/lib on my system. Which is not a place the linker would look by itself. The 'solution' at the time was to set the LD_LIBRARY_PATH env var to include /usr/local/lib. The proper solution would obviously be to reinstall libglfw and explicitly give it the correct install path.

I am unsure if this will resolve anything for you though.

codedread commented 12 years ago

I am also having the same problem on OSX (mind you, I'm fairly new to Go here). I have installed GLFW, including the dynamic library (dylib) but still getting these errors when I try to go run testdata/simplewindow/main.go

codedread commented 12 years ago

Not sure if this helps at all...

$ export DYLD_PRINT_LIBRARIES=1
$ go run testdata/simplewindow/main.go
dyld: loaded: /usr/local/go/bin/go
dyld: loaded: /usr/lib/libSystem.B.dylib
dyld: loaded: /System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation
dyld: loaded: /System/Library/Frameworks/Security.framework/Versions/A/Security
dyld: loaded: /usr/lib/system/libmathCommon.A.dylib
dyld: loaded: /usr/lib/libauto.dylib
dyld: loaded: /usr/lib/libicucore.A.dylib
dyld: loaded: /usr/lib/libobjc.A.dylib
dyld: loaded: /usr/lib/libz.1.dylib
dyld: loaded: /usr/lib/libstdc++.6.dylib
dyld: loaded: /usr/lib/libsqlite3.dylib
# command-line-arguments
dyld: loaded: /usr/local/go/pkg/tool/darwin_amd64/6g
dyld: loaded: /usr/lib/libSystem.B.dylib
dyld: loaded: /usr/lib/system/libmathCommon.A.dylib
# command-line-arguments
dyld: loaded: /usr/local/go/pkg/tool/darwin_amd64/pack
dyld: loaded: /usr/lib/libSystem.B.dylib
dyld: loaded: /usr/lib/system/libmathCommon.A.dylib
# command-line-arguments
dyld: loaded: /usr/local/go/pkg/tool/darwin_amd64/6l
dyld: loaded: /usr/lib/libSystem.B.dylib
dyld: loaded: /usr/lib/system/libmathCommon.A.dylib
/usr/local/go/pkg/darwin_amd64/github.com/jteeuwen/glfw.a(glfw.cgo2.o)(__TEXT/__text): glfwExtensionSupported: not defined
/usr/local/go/pkg/darwin_amd64/github.com/jteeuwen/glfw.a(glfw.cgo2.o)(__TEXT/__text): glfwSetTime: not defined
/usr/local/go/pkg/darwin_amd64/github.com/jteeuwen/glfw.a(glfw.cgo2.o)(__TEXT/__text): glfwGetKey: not defined
/usr/local/go/pkg/darwin_amd64/github.com/jteeuwen/glfw.a(glfw.cgo2.o)(__TEXT/__text): glfwGetNumberOfProcessors: not defined
/usr/local/go/pkg/darwin_amd64/github.com/jteeuwen/glfw.a(glfw.cgo2.o)(__TEXT/__text): glfwGetTime: not defined
/usr/local/go/pkg/darwin_amd64/github.com/jteeuwen/glfw.a(glfw.cgo2.o)(__TEXT/__text): glfwGetDesktopMode: not defined
/usr/local/go/pkg/darwin_amd64/github.com/jteeuwen/glfw.a(glfw.cgo2.o)(__TEXT/__text): glfwTerminate: not defined
/usr/local/go/pkg/darwin_amd64/github.com/jteeuwen/glfw.a(glfw.cgo2.o)(__TEXT/__text): glfwSetWindowSize: not defined
/usr/local/go/pkg/darwin_amd64/github.com/jteeuwen/glfw.a(glfw.cgo2.o)(__TEXT/__text): glfwEnable: not defined
/usr/local/go/pkg/darwin_amd64/github.com/jteeuwen/glfw.a(glfw.cgo2.o)(__TEXT/__text): glfwSleep: not defined
/usr/local/go/pkg/darwin_amd64/github.com/jteeuwen/glfw.a(glfw.cgo2.o)(__TEXT/__text): glfwOpenWindowHint: not defined
/usr/local/go/pkg/darwin_amd64/github.com/jteeuwen/glfw.a(glfw.cgo2.o)(__TEXT/__text): glfwCloseWindow: not defined
/usr/local/go/pkg/darwin_amd64/github.com/jteeuwen/glfw.a(glfw.cgo2.o)(__TEXT/__text): glfwGetWindowParam: not defined
/usr/local/go/pkg/darwin_amd64/github.com/jteeuwen/glfw.a(glfw.cgo2.o)(__TEXT/__text): glfwDisable: not defined
/usr/local/go/pkg/darwin_amd64/github.com/jteeuwen/glfw.a(glfw.cgo2.o)(__TEXT/__text): glfwGetWindowSize: not defined
/usr/local/go/pkg/darwin_amd64/github.com/jteeuwen/glfw.a(glfw.cgo2.o)(__TEXT/__text): glfwSetWindowPos: not defined
/usr/local/go/pkg/darwin_amd64/github.com/jteeuwen/glfw.a(glfw.cgo2.o)(__TEXT/__text): glfwWaitEvents: not defined
/usr/local/go/pkg/darwin_amd64/github.com/jteeuwen/glfw.a(glfw.cgo2.o)(__TEXT/__text): glfwIconifyWindow: not defined
/usr/local/go/pkg/darwin_amd64/github.com/jteeuwen/glfw.a(glfw.cgo2.o)(__TEXT/__text): glfwGetMouseWheel: not defined
/usr/local/go/pkg/darwin_amd64/github.com/jteeuwen/glfw.a(glfw.cgo2.o)(__TEXT/__text): glfwSwapBuffers: not defined
/usr/local/go/pkg/darwin_amd64/github.com/jteeuwen/glfw.a(glfw.cgo2.o)(__TEXT/__text): glfwInit: not defined
too many errors

I think this basically proves that the dynamic library at /usr/local/lib/libglfw.dylib is not being linked.

fastpars commented 12 years ago

I updated go1 to go1.0.1 and this bug gone =)

ghost commented 12 years ago

That's good to hear. Hope this applies to everyone having linking issues.

codedread commented 12 years ago

Unfortunately not me - I downloaded go1.0.1 and this is what I encountered :-/

metaleap commented 12 years ago

Hi codedread, you can try applying the 3 patch-sets mentioned in msg #2 of this thread: http://groups.google.com/group/golang-nuts/browse_thread/thread/b98c3677ec716379 -- didn't resolve my Windows-specific troubles but did get rid of the "not defined" errors during linking.

codedread commented 12 years ago

metaleap: I was able to git apply the first 2 patches, but had to do the third one (5822049) manually.

After doing this, I went to src/pkg/github.com/jteeuwen/glfw/testdata/simplewindow and typed

go run main.go

and got a tiny black window! No linker errors. Thank you! :D

metaleap commented 12 years ago

Here all got applied automatically with "git apply"s white-space-ignore-nowarn-or-some-such flags :) glad stuff worked out for you.

ghost commented 12 years ago

Good to see this is resolved for +fastpars.

+codedread, if you still have problems on OSX, could you open a separate issue for that? I suspect the problem there is a different one. It will also help me keep things a little organized here.

pwaller commented 12 years ago

My interpretation is that @codedread had fixed the issue. I'm closing this. If anyone encounters a problem please re-open or create a new issue.

ChuckAditazz commented 11 years ago

I'm currently on version go1.0.3 on Mac OS X and am having the same issues. Setting LD_LIBRARY_PATH or DYLD_LIBRARY_PATH to /usr/local/lib (where GLFW libraries are installed) doesn't help. Anyone else having these issues?

ble commented 11 years ago

@ChuckAditazz, I was having the same problem until I rebuilt the GLFW dylib with a different architecture.

Try adding the flag -m64 to CFLAGS in glfw-2.7.8/lib/cocoa/Makefile.cocoa before a make cocoa-clean and a sudo make cocoa-dist-install up at its root directory.