尝试在Mac上编译GLFW时GLFW上的链接器错误
Linker error on GLFW when trying to compile GLFW on Mac
我正在尝试在带有xcode的Mac上使用glfw 2.7.5,但是出现以下错误:
Undefined symbols for architecture i386:
"_glfwGetKey", referenced from:
Game::run() in Game.o
RedScene::update(float, bool) in main.o
"_glfwGetWindowParam", referenced from:
Game::run() in Game.o
"_glfwInit", referenced from:
Window::Window() in Window.o
"_glfwOpenWindow", referenced from:
createWindow(int, int, int, int, int, int, int, int) in Window.o
"_glfwOpenWindowHint", referenced from:
Window::Window() in Window.o
"_glfwPollEvents", referenced from:
Game::run() in Game.o
"_glfwSetKeyCallback", referenced from:
createWindow(int, int, int, int, int, int, int, int) in Window.o
"_glfwSetMouseButtonCallback", referenced from:
createWindow(int, int, int, int, int, int, int, int) in Window.o
"_glfwSetMousePosCallback", referenced from:
createWindow(int, int, int, int, int, int, int, int) in Window.o
"_glfwSetMouseWheelCallback", referenced from:
createWindow(int, int, int, int, int, int, int, int) in Window.o
"_glfwSetWindowTitle", referenced from:
Window::setCaption(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) in Window.o
"_glfwSwapBuffers", referenced from:
RedScene::update(float, bool) in main.o
"_glfwSwapInterval", referenced from:
createWindow(int, int, int, int, int, int, int, int) in Window.o
"_glfwTerminate", referenced from:
Window::~Window() in Window.o
ld: symbol(s) not found for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)
我已经阅读了使用 GLFW 和 XCode 的问题:无法编译和互联网上的其他几个链接,但我找不到解决方案。
我已经设置了Cocoa框架,OpenGL框架和libglfw.a(我使用"sudo make cocoa-install"编译),在我设置的链接器标志中-lgflw,我正在为32位英特尔构建。起初我正在为 64 位构建,但我认为 GLFW 在 Mac 上还不支持它(我收到操纵杆文件错误),当我编译为 32 位时错误会发生变化,它找不到我正在使用的功能。知道我能做些什么来解决这个问题吗?
很可能您已经为 64 位构建了 libglfw.a,因此当您尝试在 32 位应用程序中使用它时会出现链接错误。您可以重建 32 位的 libglfw.a(或作为"胖"32 位和 64 位库),也可以将应用程序构建为 64 位。
请注意,在最新版本的 Mac OS X 和 Xcode 中,gcc 默认构建 64 位代码,因此您需要在命令行上指定-m32
以获取 32 位代码。在实践中如何执行此操作取决于 libglfw.a 的 makefile - 很可能有一个 ARCH
或其他符号,您可以在命令行上指定它们来强制 32 位构建。
相关文章:
- 无法将 GLFW 库与 Ubuntu 18.04 上的头文件链接
- GLFW需要链接什么?
- 对GLFW / Vulkan的未定义引用,尽管库似乎是链接的
- 编译器无法链接/查找 GLFW
- 链接Visual Studio代码中的GLFW
- 使用 CMake 在 Mac 上链接静态 GLFW 和 OpenGL
- 如何在Linux中使用GLFW函数正确链接C++对象?
- 为什么我需要FreeGLUT来编译和链接GLFW程序
- Vulkan + GLFW + Cmake在Linux环境下的链接问题
- Linux(X11)上GLFW上的链接器错误
- Glew - 与 GLFW 配对时 gl- 函数符号上出现链接错误
- libigl,GLEW,GLFW和Eigen在CLion,Windows 10上.链接器错误
- 在 Fedora 27 中构建 GLFW 时链接期间出错
- 如何将正确的库与 GLFW 链接为 cmake 中的外部项目
- GLFW 链接问题 Visual Studio 2012.
- GLFW MinGW 链接错误
- 尝试在Mac上编译GLFW时GLFW上的链接器错误
- 无法获取 GLFW 链接
- 在 Windows 10 上的 VS 2015 中与 nupengl GLFW 链接错误
- GLFW链接不能正常工作与mingw32在c++ (?)