How to get up & running under Mac OS

anonymous wrote on Tuesday, October 23, 2012:

Note, I’m using a GLFW binding for Go, right now I’m not sure if my problem is
installing GLFW properly under OSX, or whether there is just an issue in the
Go binding.

First I downloaded libGLFW 2.7.6 and as per the readme, did a **make
cocoa**. Couple of compiler warnings about use of deprecated functions etc.
No errors as far as I can tell. Then **sudo make cocoa-install**, output:

cd lib/cocoa && make -f Makefile.cocoa
make: Nothing to be done for `all’.
cd examples && make -f Makefile.cocoa
make: Nothing to be done for `all’.
cd tests && make -f Makefile.cocoa
make: Nothing to be done for `all’.
cd lib/cocoa && make -f Makefile.cocoa install
sed -e ‘s,@PREFIX@,/usr/local,’ libglfw.pc.in > libglfw.pc
install -d /usr/local/lib
install -c -m 644 libglfw.a /usr/local/lib/libglfw.a
ranlib /usr/local/lib/libglfw.a
install -d /usr/local/include/GL
install -c -m 644 …/…/include/GL/glfw.h /usr/local/include/GL/glfw.h
install -d /usr/local/lib/pkgconfig
install -c -m 644 libglfw.pc /usr/local/lib/pkgconfig/libglfw.pc

Not sure if that output looks good or not - but I don’t see any glaring error
messages per se. But did it make any examples? If so, are they located as
terminal-runnable binaries in the examples folder, or where?

Next, the libglfw readme states: **Note that the shared library is not
installed by default| GLFW is very small and very suitable for static
linking.** Well… *PROBLEM* - IIRC, for Cgo-based “go-glfw”, linking
dynamically is preferred / the only option, right? So… I’m not a pro on OSX /
elf “DLL” schemes - which one of the dynamic lib, just libglfw.dylib? And
where do I put this under OSX so that when I finally *do* “go get github.com
/go-gl/glfw”, I don’t get the following error output, which I just got right
now - note this basically error output from a C compilation stage, so not
necessarily strictly a “problem due to Go” I believe:

# github.com/go-gl/glfw
Undefined symbols for architecture x86_64:
"_IOMasterPort", referenced from:
__glfwInitJoysticks in libglfw.a(cocoa_joystick.o)
"_IOServiceMatching", referenced from:
__glfwInitJoysticks in libglfw.a(cocoa_joystick.o)
"_IOServiceGetMatchingServices", referenced from:
__glfwInitJoysticks in libglfw.a(cocoa_joystick.o)
"_IOIteratorNext", referenced from:
__glfwInitJoysticks in libglfw.a(cocoa_joystick.o)
"_IORegistryEntryCreateCFProperties", referenced from:
__glfwInitJoysticks in libglfw.a(cocoa_joystick.o)
"_IOCreatePlugInInterfaceForService", referenced from:
__glfwInitJoysticks in libglfw.a(cocoa_joystick.o)
ld: symbol(s) not found for architecture x86_64
collect2: ld returned 1 exit status

Would love any ideas / insights…

elmindreda wrote on Tuesday, October 23, 2012:

To install the dynamic library as well, use the cocoa-dist-install target.

The examples are in the examples directory.

The link errors are due to you needing to link against the IOKit framework,
which is used by the OS X joystick code. See the readme section 4.2.5 for
details.

anonymous wrote on Wednesday, October 24, 2012:

All good, cocoa-dist-install did the trick! Joysticks are not a priority at
this point and somehow after dist-install that error didn’t show up anymore.

elmindreda wrote on Wednesday, October 24, 2012:

The linker prefers dynamic libraries, so when both are present that’s the one
chosen. Since it’s a complete binary, it’s already linked against everything
it needs.