2012-07-20 36 views
8

Problems linking against GLFW in OSXVấn đề liên kết GLFW trong makefile trên OSX Lion

Tôi đã đọc điều này nhưng có vẻ như đây là vấn đề khác với tôi.

Lệnh là ran trong makefile là,

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

Các lỗi mà tôi nhận được khi tôi chạy makefile là,

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 

Trả lời

16

Thêm -framework IOKit để g ++ tùy chọn.

+0

Cảm ơn bạn rất nhiều! – snarehanger

+0

Bạn đã lưu ngày của tôi :-) – Mayoneez

+1

Chỉ cần thêm một số chi tiết ở đây: khung IOKit là bắt buộc vì nó được sử dụng bởi hỗ trợ phím điều khiển OS X được thêm gần đây. – elmindreda

0

Thsnks để @ Mārtiņš Možeiko, tôi giải quyết một phần của vấn đề, nhưng đối với tôi vẫn còn vài thông báo lỗi:

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 

Để giải quyết nó, tôi cũng cần thêm khuôn khổ CoreVideo.

-framework Cocoa -framework IOKit -framework CoreVideo -framework OpenGL 
Các vấn đề liên quan