Problems linking against GLFW in OSX
I've read this already but it seems to be a different issue with me.
The command being ran in the makefile is,
g++ -o main main.cpp -lglfw -framework Cocoa -framework OpenGL
The error that I'm receiving when I run the makefile is,
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
将-framework IOKit
添加到g ++选项。
Thsnks to @Mārtiņš Možeiko, I solved part of the problem, but for me there were still few error messages :
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
To solve it, I also needed to add the CoreVideo framework.
-framework Cocoa -framework IOKit -framework CoreVideo -framework OpenGL
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.