我刚开始在Mac上构建命令行。在使用OpenGL、IMGui和GLFW开发跨平台应用程序时,我不断收到链接错误:
Undefined symbols for architecture x86_64:
"__glfwCreateContextEGL", referenced from:
__glfwPlatformCreateWindow in libGLFW.a(cocoa_window.o)
"__glfwCreateContextNSGL", referenced from:
__glfwPlatformCreateWindow in libGLFW.a(cocoa_window.o)
"__glfwCreateContextOSMesa", referenced from:
__glfwPlatformCreateWindow in libGLFW.a(cocoa_window.o)
"__glfwInitEGL", referenced from:
__glfwPlatformCreateWindow in libGLFW.a(cocoa_window.o)
"__glfwInitNSGL", referenced from:
__glfwPlatformCreateWindow in libGLFW.a(cocoa_window.o)
"__glfwInitOSMesa", referenced from:
__glfwPlatformCreateWindow in libGLFW.a(cocoa_window.o)
"__glfwPlatformCreateMutex", referenced from:
_glfwInit in libGLFW.a(init.o)
"__glfwPlatformCreateTls", referenced from:
_glfwInit in libGLFW.a(init.o)
"__glfwPlatformDestroyMutex", referenced from:
_terminate in libGLFW.a(init.o)
"__glfwPlatformDestroyTls", referenced from:
_terminate in libGLFW.a(init.o)
"__glfwPlatformGetTls", referenced from:
_glfwDestroyWindow in libGLFW.a(window.o)
__glfwRefreshContextAttribs in libGLFW.a(context.o)
_glfwMakeContextCurrent in libGLFW.a(context.o)
_glfwExtensionSupported in libGLFW.a(context.o)
_glfwGetCurrentContext in libGLFW.a(context.o)
_glfwSwapInterval in libGLFW.a(context.o)
_glfwGetProcAddress in libGLFW.a(context.o)
...
"__glfwPlatformLockMutex", referenced from:
__glfwInputError in libGLFW.a(init.o)
"__glfwPlatformSetTls", referenced from:
__glfwInputError in libGLFW.a(init.o)
_glfwInit in libGLFW.a(init.o)
"__glfwPlatformUnlockMutex", referenced from:
__glfwInputError in libGLFW.a(init.o)
"__glfwTerminateNSGL", referenced from:
__glfwPlatformTerminate in libGLFW.a(cocoa_init.o)
"__glfwUpdateDisplayLinkDisplayNSGL", referenced from:
-[GLFWWindowDelegate windowDidChangeScreen:] in libGLFW.a(cocoa_window.o)
我链接到可可、CoreVideo和IOKit框架。知道我遗漏了什么吗?
2条答案
按热度按时间vfwfrxfs1#
你好可能已经发现了你的错误,而做类似的事情,你忘了链接到几个库是必需的...
“g++ -o测试main.c libGLEW.a libglfw3.a -框架opengl -框架可可-框架IOKit”
来源:https://web.eecs.umich.edu/~sugih/courses/eecs487/glfw-howto/
cmssoen22#
我有一个类似的问题,你当试图建立GLFW对我自己。它似乎好像当建立GLFW你没有包括所有需要的文件。
构建时,当前版本的GLFW中需要以下macOS特定的文件:
特别是对于您,请确保包含
egl_context.c
、nsgl_context.m
和posix_thread.c
。