GLFW linking issue in makefile on OSX Lion
Asked Answered
O

2

9

Problems linking against GLFW in OSX

I've read this already but it seems to be a different issue with me.

The command being ran in the makefile is,

    g++ -o main main.cpp -lglfw -framework Cocoa -framework OpenGL

The error that I'm receiving when I run the makefile is,

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
make: *** [all] Error 1
Overjoy answered 20/7, 2012 at 2:46 Comment(0)
B
16

Add -framework IOKit to g++ options.

Both answered 20/7, 2012 at 3:13 Comment(1)
Just adding some detail here: the IOKit framework is required because it's used by the recently added OS X joystick support.Feuchtwanger
F
2

Thsnks to @Mārtiņš Možeiko, I solved part of the problem, but for me there were still few error messages :

Undefined symbols for architecture x86_64:
  "_CVDisplayLinkCreateWithCGDisplay", referenced from:
      __glfwSetVideoMode in libglfw3.a(cocoa_monitor.m.o)
      __glfwPlatformGetVideoMode in libglfw3.a(cocoa_monitor.m.o)
      __glfwPlatformGetVideoModes in libglfw3.a(cocoa_monitor.m.o)
  "_CVDisplayLinkGetNominalOutputVideoRefreshPeriod", referenced from:
      _vidmodeFromCGDisplayMode in libglfw3.a(cocoa_monitor.m.o)
  "_CVDisplayLinkRelease", referenced from:
      __glfwSetVideoMode in libglfw3.a(cocoa_monitor.m.o)
      __glfwPlatformGetVideoMode in libglfw3.a(cocoa_monitor.m.o)
      __glfwPlatformGetVideoModes in libglfw3.a(cocoa_monitor.m.o)
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[1]: *** [scop] Error 1
make: *** [scop] Error 2

To solve it, I also needed to add the CoreVideo framework.

-framework Cocoa -framework IOKit -framework CoreVideo -framework OpenGL
Farrica answered 17/7, 2015 at 11:27 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.