2012-07-20 58 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