0

I am new to C++ and trying to create a window with OpenGL. My program gives the error undefined reference to 'glutSwapBuffers'. I did not understand why is it giving this error for hours but I just looked and saw that the glutSwapBuffers function is defined like this in my header file:

extern void APIENTRY glutSwapBuffers(void);

I edited the header and changed it to an example function and the function worked. I searched for GLUT and downloaded the header files that I found. Definition was always same.

I understood why does not my code work but I do not know why the glutSwapBuffers is defined like this. Do I need to include other libraries?

bapap
  • 514
  • 8
  • 25
  • An undefined reference error is a LINKER error. You have supplied the header with the definition, but the linker isn't able to find the implementation (which is in a lib/dll). – BDL Apr 13 '20 at 20:57
  • Do I need to link the `.lib` files in lib directory that I downloaded? – bapap Apr 13 '20 at 21:02
  • Probably. Depends on the compiler used and on the lib you downloaded. – BDL Apr 13 '20 at 21:26
  • There are a lot of library. Which one do I need to link and how will I link? I am using MinGW. – bapap Apr 13 '20 at 21:29

0 Answers0