【发布时间】:2014-02-25 23:36:46
【问题描述】:
它列出的未定义引用在“glew.h”中明确设置。我已将库包含在链接器中,包含在搜索目录中,并将 glew32.dll 复制到系统注册表中(以及许多其他地方 - MinGW 目录中的几个位置以及调试目录)。我在他们的网站上使用了最新版本的 GLEW,尽管 codeBlocks 和 freeGlut 是在 10 月/11 月下载回来的。我正在尝试遵循关于 OpenGL/Glut 的 swiftless 教程。
很明显,调试器没有正确链接库/头文件,但我不知道为什么 - 我到处搜索,有一些关于使 minGW 静态的事情我不太明白,但听起来就像它不需要为了它工作而完成一样。
错误意大利面:
-------------- Build: Debug in Window Tutorial (compiler: GNU GCC Compiler)---------------
mingw32-g++.exe -LC:\glew-1.10.0\include\GL
-LC:\freeglut\include\GL
-LC:\freeglut\lib
-LC:\glew-1.10.0\lib\Release\Win32
-o "bin\Debug\Window Tutorial.exe"
obj\Debug\main.o
C:\glew-1.10.0\lib\Release\Win32\glew32.lib
C:\glew-1.10.0\lib\Release\Win32\glew32s.lib
C:\freeglut\lib\glut32.lib
C:\freeglut\lib\libfreeglut.a
C:\freeglut\lib\libfreeglut_static.a
obj\Debug\main.o: In function `display':
C:/Users/CNOVDM/Other/codeBlocks/Swiftless/Window/Window Tutorial/main.c:5: undefined reference to `glClearColor@16'
C:/Users/CNOVDM/Other/codeBlocks/Swiftless/Window/Window Tutorial/main.c:6: undefined reference to `glClear@4'
C:/Users/CNOVDM/Other/codeBlocks/Swiftless/Window/Window Tutorial/main.c:7: undefined reference to `glLoadIdentity@0'
C:/Users/CNOVDM/Other/codeBlocks/Swiftless/Window/Window Tutorial/main.c:9: undefined reference to `glFlush@0'
collect2.exe: error: ld returned 1 exit status
Process terminated with status 1 (0 minutes, 4 seconds)
4 errors, 0 warnings (0 minutes, 4 seconds)
代码:
#include <glew.h>
#include <glut.h>
void display (void) {
glClearColor(1.0f, 0.0f, 0.0f, 1.0f); //Clear the background of our window to red
glClear(GL_COLOR_BUFFER_BIT); //Clear the colour buffer (more buffers later on)
glLoadIdentity(); // Load the Identity Matrix to reset our drawing locations
glFlush(); // Flush the OpenGL buffers to the window
}
int main (int argc, char **argv) {
glutInit(&argc, argv); // Initialize GLUT
glewInit();
glutInitDisplayMode(GLUT_SINGLE); //Set Up a basic Display Buffer (only single buffered for now)
glutInitWindowSize(500,500); // Set the width and height of the window
glutInitWindowPosition(100,100); // set the position of the window
glutCreateWindow("My First OpenGL Window"); // Set the title for the window
glutDisplayFunc(display); // Tell GLUT to use the method "display" for rendering
glutMainLoop(); // Enter GLUT's main loop
}
【问题讨论】:
-
1. 如何将 DLL 复制到系统注册表中?如果您的意思是将其复制到
Windows\System32或Windows\SysWOW64中,请不要这样做。 2.这些与GLEW无关,你忘了链接到opengl32.lib。 -
你是对的。我关注的教程用于 Visual Studio - 我猜默认情况下已经链接了它,因为它从未被提及。感谢您帮助解决如此愚蠢的错误。 swiftless.com/tutorials/opengl/window.html 哦,是的,我的意思是我把它放到了系统文件夹中。我没有 64 位操作系统 - 所以它只是 System32。
标签: windows opengl codeblocks glew freeglut