【发布时间】:2017-05-23 17:40:18
【问题描述】:
所以我正在从openglbook 学习 OpenGL 4。
我将简单的窗口创建程序复制并粘贴到我的编辑器中,然后使用 Compiling OpenGL programs on OS X 跟踪
gcc -o hello hello.c -framework OpenGL -framework GLUT
我收到以下错误:
Undefined symbols for architecture x86_64:
"_glewGetErrorString", referenced from:
_Initialize in chapter-c8ba2d.o
"_glewInit", referenced from:
_Initialize in chapter-c8ba2d.o
"_glutInitContextFlags", referenced from:
_InitWindow in chapter-c8ba2d.o
"_glutInitContextProfile", referenced from:
_InitWindow in chapter-c8ba2d.o
"_glutInitContextVersion", referenced from:
_InitWindow in chapter-c8ba2d.o
"_glutSetOption", referenced from:
_InitWindow in chapter-c8ba2d.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
【问题讨论】:
-
看起来 GLUT 未找到或不是为 x86_64 构建的。此页面可能会有所帮助:web.eecs.umich.edu/~sugih/courses/eecs487/glut-howto/#mac
-
在我使用 c 学习 OpenGL 4 之前,我使用的是带有 c++ 的 OpenGL。当我用
g++ -o out out.cpp -framework OpenGL -framework GLUT编译我的程序时,它工作得很好。这是否意味着我的 GLUT 已构建,只是没有找到?谢谢 -
唯一没有找到的符号来自 glut 和 glew。我假设您在某处有其他 gl 调用,这意味着它可以很好地链接到 OpenGL 框架。
-
GLEW 与 GLUT 和 OpenGL 是分开的。不是吗?