0

I'm a new programmer in general, so installing libraries isn't something I do very often. I am making a basic OpenGL/GLUT app and after compiling with some test code I got a bunch of undefined references:

main.o:main.c:(.text+0x1c): undefined reference to `__glutInitWithExit@12'
main.o:main.c:(.text+0x3c): undefined reference to `__glutCreateWindowWithExit@8'
main.o:main.c:(.text+0x5c): undefined reference to `__glutCreateMenuWithExit@8'
main.o:main.c:(.text+0x75): undefined reference to `glClear@4'
main.o:main.c:(.text+0x97): undefined reference to `glColor3f@12'
main.o:main.c:(.text+0xa6): undefined reference to `glBegin@4'
main.o:main.c:(.text+0xbf): undefined reference to `glVertex2f@8'
main.o:main.c:(.text+0xd8): undefined reference to `glVertex2f@8'
main.o:main.c:(.text+0xf1): undefined reference to `glVertex2f@8'
main.o:main.c:(.text+0x10a): undefined reference to `glVertex2f@8'
main.o:main.c:(.text+0x112): undefined reference to `glEnd@0'
main.o:main.c:(.text+0x117): undefined reference to `glFlush@0'
main.o:main.c:(.text+0x11c): undefined reference to `glutSwapBuffers@0'
main.o:main.c:(.text+0x155): undefined reference to `glutInitDisplayMode@4'
main.o:main.c:(.text+0x16c): undefined reference to `glutInitWindowSize@8'
main.o:main.c:(.text+0x18a): undefined reference to `glutDisplayFunc@4'
main.o:main.c:(.text+0x1d9): undefined reference to `gluOrtho2D@32'
main.o:main.c:(.text+0x204): undefined reference to `glClearColor@16'
main.o:main.c:(.text+0x20c): undefined reference to `glutMainLoop@0'

I have checked all the files I installed and they are in the correct place according to my guide. I'll leave the test code below.

#include <windows.h>
#include <GL/glut.h>

void display()
{
 glClear(GL_COLOR_BUFFER_BIT);
 glColor3f(1,0,0);
 glBegin(GL_POLYGON);
 glVertex2f(100,300);
 glVertex2f(100,100);
 glVertex2f(200,100);
 glVertex2f(200,300);
 glEnd();
 glFlush();
 glutSwapBuffers();
}

int main(int argc, char** argv)
{ 
 glutInit(&argc, argv);
 glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGBA);
 glutInitWindowSize(640,640);
 glutCreateWindow("OpenGL");
 glutDisplayFunc(display);
 gluOrtho2D(0,640,0,640);
 glClearColor(0.5,0.7,0.5,0);
 glutMainLoop();
 return 0;
}
BDL
  • 21,052
  • 22
  • 49
  • 55

0 Answers0