【问题标题】:GLFW linking issue in makefile on OSX LionOSX Lion 上的 makefile 中的 GLFW 链接问题
【发布时间】:2012-07-19 07:19:18
【问题描述】:

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

【问题讨论】:

    标签: c++ macos opengl makefile glfw


    【解决方案1】:

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

    【讨论】:

    • 这里只是添加一些细节:IOKit 框架是必需的,因为它被最近添加的 OS X 操纵杆支持所使用。
    【解决方案2】:

    感谢@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
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-06-26
      • 2011-10-19
      相关资源
      最近更新 更多