0

错误!

ld: warning: ignoring file /opt/homebrew/Cellar/glfw/3.3.2/lib/libglfw.3.dylib, building for macOS-x86_64 but attempting to link with file built for macOS-arm64
Undefined symbols for architecture x86_64:
  "_glfwCreateWindow", referenced from:
      GLWindow::GLWindow(int, int, char*) in MagicCubeLauncher.cpp.o
  "_glfwDestroyWindow", referenced from:
      GLWindow::~GLWindow() in MagicCubeLauncher.cpp.o
  "_glfwGetKey", referenced from:
      Render::processInput() in MagicCubeLauncher.cpp.o
  "_glfwGetProcAddress", referenced from:
      GLWindow::GLWindow(int, int, char*) in MagicCubeLauncher.cpp.o
  "_glfwGetTime", referenced from:
      Render::initRenderLayer() in MagicCubeLauncher.cpp.o
      getTime() in MagicCubeLauncher.cpp.o
  "_glfwInit", referenced from:
      Shader::Shader(char const*, char const*) in MagicCubeLauncher.cpp.o
      GLWindow::GLWindow(int, int, char*) in MagicCubeLauncher.cpp.o
  "_glfwMakeContextCurrent", referenced from:
      GLWindow::GLWindow(int, int, char*) in MagicCubeLauncher.cpp.o
  "_glfwPollEvents", referenced from:
      Render::initRenderLayer() in MagicCubeLauncher.cpp.o
  "_glfwSetCursorPosCallback", referenced from:
      Render::init() in MagicCubeLauncher.cpp.o
  "_glfwSetFramebufferSizeCallback", referenced from:
      Render::init() in MagicCubeLauncher.cpp.o
  "_glfwSetInputMode", referenced from:
      Render::processInput() in MagicCubeLauncher.cpp.o
  "_glfwSetScrollCallback", referenced from:
      Render::init() in MagicCubeLauncher.cpp.o
  "_glfwSetWindowShouldClose", referenced from:
      Render::processInput() in MagicCubeLauncher.cpp.o
  "_glfwSwapBuffers", referenced from:
      Render::initRenderLayer() in MagicCubeLauncher.cpp.o
  "_glfwTerminate", referenced from:
      GLWindow::GLWindow(int, int, char*) in MagicCubeLauncher.cpp.o
      Render::clear() in MagicCubeLauncher.cpp.o
  "_glfwWindowHint", referenced from:
      GLWindow::GLWindow(int, int, char*) in MagicCubeLauncher.cpp.o
  "_glfwWindowShouldClose", referenced from:
      Render::initRenderLayer() in MagicCubeLauncher.cpp.o
ld: symbol(s) not found for architecture x86_64

可以直接用Rosetta 2翻译成arm64框架使用吗?

如果不是,是否有任何其他方法可以用来在这个框架上运行它,或者我需要等待 glew 和 glfw 来支持它?

4

1 回答 1

1

我之前遇到过这个问题,我终于找到了解决办法。这里发生的事情是您的编译器正在为错误的架构构建。您需要指定要为苹果芯片进行编译以使其正常工作。由于您没有指定您的构建系统,我将使用我使用的,在这种情况下,是 CMake。

您需要添加的只是CMAKE_APPLE_SILICON_PROCESSOR选项,如下所示:

# Inside of your `build` directory
$ cmake -DCMAKE_APPLE_SILICON_PROCESSOR=arm64 ..

如果没有这个,我的代码会明确指定x86_64架构并抛出您发布的错误。这可能不是灵丹妙药,但这就是我解决上述问题的方法。您需要为您的系统执行与此等效的任何操作,或者如果您手动编译,则明确指定体系结构。

于 2021-02-15T17:53:03.507 回答