GLFW在OSX Lion上的makefile中链接问题

时间:2012-07-20 02:46:36

标签: c++ macos opengl makefile glfw

Problems linking against GLFW in OSX

我已经读过这篇文章,但这对我来说似乎是一个不同的问题。

在makefile中运行的命令是,

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

我运行makefile时收到的错误是

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

2 个答案:

答案 0 :(得分:16)

-framework IOKit添加到g ++选项。

答案 1 :(得分:1)

向@MārtiņšMožeiko致谢,我解决了部分问题,但对我来说仍有一些错误消息:

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

要解决这个问题,我还需要添加CoreVideo框架。

-framework Cocoa -framework IOKit -framework CoreVideo -framework OpenGL