**已关闭。**此问题需要debugging details。当前不接受答案。
编辑问题以包含desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem。这将有助于其他人回答问题。
6个月前关闭。
Improve this question
我已经包含了库〈GLUT/glut.h〉,并且所有语法都是正确的,但是我还是收到了这个错误。
Undefined symbols for architecture arm64:
"_glBegin", referenced from:
triangle(float*, float*, float*) in main.cpp.o
"_glClear", referenced from:
displayTriangle() in main.cpp.o
"_glClearColor", referenced from:
_main in main.cpp.o
"_glColor3f", referenced from:
drawTetrahedron(int) in main.cpp.o
"_glEnable", referenced from:
_main in main.cpp.o
"_glEnd", referenced from:
triangle(float*, float*, float*) in main.cpp.o
"_glFlush", referenced from:
displayTriangle() in main.cpp.o
"_glLoadIdentity", referenced from:
displayTriangle() in main.cpp.o
"_glMatrixMode", referenced from:
reshapeWindow(int, int) in main.cpp.o
"_glOrtho", referenced from:
reshapeWindow(int, int) in main.cpp.o
"_glVertex3fv", referenced from:
triangle(float*, float*, float*) in main.cpp.o
"_glViewport", referenced from:
reshapeWindow(int, int) in main.cpp.o
"_glutCreateWindow", referenced from:
_main in main.cpp.o
"_glutDisplayFunc", referenced from:
_main in main.cpp.o
"_glutInit", referenced from:
_main in main.cpp.o
"_glutInitDisplayMode", referenced from:
_main in main.cpp.o
"_glutInitWindowSize", referenced from:
_main in main.cpp.o
"_glutMainLoop", referenced from:
_main in main.cpp.o
"_glutPostRedisplay", referenced from:
reshapeWindow(int, int) in main.cpp.o
"_glutReshapeFunc", referenced from:
_main in main.cpp.o
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
ninja: build stopped: subcommand failed.
我觉得我的cmakefile是我的问题,但我不知道从哪里开始。
1条答案
按热度按时间f4t66c6m1#
请提供更多详细信息,如CMakeLists.txt的相关部分,以便从社区获得更多信息和更快的帮助。
现在,转到错误日志,您似乎正在使用基于arm的编译器交叉编译源文件。
显示错误消息“ld:找不到架构arm 64的符号”在我看来是链接器问题,您应该在OpenGL的CMakeLists.txt中进行find_package()和链接调用。
因此,首先,您应该按照两个步骤开始,看看它是否能解决您的问题:
1.确保CMake构建系统指向正确的编译器工具链路径(此处为arm编译器)。
请参考CMake官方网站:https://cmake.org/cmake/help/book/mastering-cmake/chapter/Cross%20Compiling%20With%20CMake.html
2.确保您链接的是OpenGL
查找包(需要OpenGL)
目标包含目录(您的可执行文件名称PUBLIC ${OPENGL_INCLUDE_DIR})
目标链接库(您的可执行文件名称PUBLIC ${OPENGL库})