使用命令行在Mac上构建OpenGL应用程序时出现链接错误

bxgwgixi  于 2022-11-04  发布在  Mac
关注(0)|答案(2)|浏览(235)

我刚开始在Mac上构建命令行。在使用OpenGL、IMGui和GLFW开发跨平台应用程序时,我不断收到链接错误:

  1. Undefined symbols for architecture x86_64:
  2. "__glfwCreateContextEGL", referenced from:
  3. __glfwPlatformCreateWindow in libGLFW.a(cocoa_window.o)
  4. "__glfwCreateContextNSGL", referenced from:
  5. __glfwPlatformCreateWindow in libGLFW.a(cocoa_window.o)
  6. "__glfwCreateContextOSMesa", referenced from:
  7. __glfwPlatformCreateWindow in libGLFW.a(cocoa_window.o)
  8. "__glfwInitEGL", referenced from:
  9. __glfwPlatformCreateWindow in libGLFW.a(cocoa_window.o)
  10. "__glfwInitNSGL", referenced from:
  11. __glfwPlatformCreateWindow in libGLFW.a(cocoa_window.o)
  12. "__glfwInitOSMesa", referenced from:
  13. __glfwPlatformCreateWindow in libGLFW.a(cocoa_window.o)
  14. "__glfwPlatformCreateMutex", referenced from:
  15. _glfwInit in libGLFW.a(init.o)
  16. "__glfwPlatformCreateTls", referenced from:
  17. _glfwInit in libGLFW.a(init.o)
  18. "__glfwPlatformDestroyMutex", referenced from:
  19. _terminate in libGLFW.a(init.o)
  20. "__glfwPlatformDestroyTls", referenced from:
  21. _terminate in libGLFW.a(init.o)
  22. "__glfwPlatformGetTls", referenced from:
  23. _glfwDestroyWindow in libGLFW.a(window.o)
  24. __glfwRefreshContextAttribs in libGLFW.a(context.o)
  25. _glfwMakeContextCurrent in libGLFW.a(context.o)
  26. _glfwExtensionSupported in libGLFW.a(context.o)
  27. _glfwGetCurrentContext in libGLFW.a(context.o)
  28. _glfwSwapInterval in libGLFW.a(context.o)
  29. _glfwGetProcAddress in libGLFW.a(context.o)
  30. ...
  31. "__glfwPlatformLockMutex", referenced from:
  32. __glfwInputError in libGLFW.a(init.o)
  33. "__glfwPlatformSetTls", referenced from:
  34. __glfwInputError in libGLFW.a(init.o)
  35. _glfwInit in libGLFW.a(init.o)
  36. "__glfwPlatformUnlockMutex", referenced from:
  37. __glfwInputError in libGLFW.a(init.o)
  38. "__glfwTerminateNSGL", referenced from:
  39. __glfwPlatformTerminate in libGLFW.a(cocoa_init.o)
  40. "__glfwUpdateDisplayLinkDisplayNSGL", referenced from:
  41. -[GLFWWindowDelegate windowDidChangeScreen:] in libGLFW.a(cocoa_window.o)

我链接到可可、CoreVideo和IOKit框架。知道我遗漏了什么吗?

vfwfrxfs

vfwfrxfs1#

你好可能已经发现了你的错误,而做类似的事情,你忘了链接到几个库是必需的...
“g++ -o测试main.c libGLEW.a libglfw3.a -框架opengl -框架可可-框架IOKit”
来源:https://web.eecs.umich.edu/~sugih/courses/eecs487/glfw-howto/

cmssoen2

cmssoen22#

我有一个类似的问题,你当试图建立GLFW对我自己。它似乎好像当建立GLFW你没有包括所有需要的文件。
构建时,当前版本的GLFW中需要以下macOS特定的文件:

  1. src/cocoa_init.m
  2. src/cocoa_joystick.m
  3. src/cocoa_monitor.m
  4. src/cocoa_window.m
  5. src/cocoa_time.c
  6. src/posix_thread.c
  7. src/nsgl_context.m
  8. src/egl_context.c
  9. src/osmesa_context.c
  10. src/posix_module.c

特别是对于您,请确保包含egl_context.cnsgl_context.mposix_thread.c

相关问题