Question

The undefined references that it lists are clearly set up in 'glew.h.' I have included the libraries in the linker, the includes in the search directories, and have copied the glew32.dll into the system registry (as well as a bunch of other places - several spots inside MinGW's directory as well as the debug directory). I am using the most recent version of GLEW on their website, though codeBlocks and freeGlut were downloaded back in October/November. I'm attempting to follow the swiftless tutorial on OpenGL/Glut.

Clearly, the debugger is not linking the libraries/header correctly, but I can't figure out why - I've searched everywhere, and there's some things about making minGW static that I don't quite understand, but it sounds like it doesn't need to be done in order for it to work.

Error pasta:

-------------- 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)

The code:

#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
}
Was it helpful?

Solution

I think you forgot to link to the lib files.

read the manual 1.11.13.

If you use x64 system, you should put the glew32.dll in lib\release\x64 to System32, and the other on in lib\release\Win32 to SysWOW64

this link will help you to understand it.

OTHER TIPS

As far as I know, you still need to link with GL even if you link with glew. try adding -lopengl32

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top