2012-07-20 62 views
8

Problems linking against GLFW in OSXGLFW在OSX狮子

连接在生成文件的问题,我已经阅读过这一点,但它似乎是一个不同的问题和我在一起。

在生成文件所述命令被RAN为,

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

当我运行生成文件是我收到的错误,

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 

回答

16

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

+0

非常感谢! – snarehanger 2012-07-20 11:30:33

+0

您节省了我的日子:-) – Mayoneez 2012-07-20 18:56:12

+1

只需在此添加一些细节:IOKit框架是必需的,因为最近添加的OS X游戏杆支持使用了它。 – elmindreda 2012-08-20 13:43:03

0

Thsnks到@马丁斯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