samedi 28 février 2015

OpenGL - Undefined references to GLUT

I'm having a problem getting openGL to work on Windows 7 using MinGW at the moment. I'm following the steps found here: http://ift.tt/1EWAuOZ


I have installed MinGW and all of it's basic installation files. I have added the elements required to my PATH variable. I have downloaded and placed the GLUT files in the correct directories as described in the link above. Even so, with the below code I get the subsequent errors.



#include <GL/glut.h>

void display (void)
{
glClear (GL_COLOR_BUFFER_BIT);

glBegin (GL_POLYGON);
glVertex2f (-0.5, -0.5);
glVertex2f (-0.5, 0.5);
glVertex2f (0.5, 0.5);
glVertex2f (0.5, -0.5);
glEnd ();

glFlush ();
return;
}

int main (int argc, char **argv)
{
glutInit (&argc, argv);
glutCreateWindow ("simple");
glutDisplayFunc (display);
glutMainLoop ();
}


The command used to compile this program is: gcc firstProg.c -o firstProg.exe glut32.lib -lopengl32 -lglu32


The error is as follows (taken from the cmd):



C:\Users\Dylan\AppData\Local\Temp\cciCuMP6.o:firstProg.c:(.text+0x1c): undefined
reference to `__glutInitWithExit'
C:\Users\Dylan\AppData\Local\Temp\cciCuMP6.o:firstProg.c:(.text+0x37): undefined
reference to `__glutCreateWindowWithExit'
C:\Users\Dylan\AppData\Local\Temp\cciCuMP6.o:firstProg.c:(.text+0x52): undefined
reference to `__glutCreateMenuWithExit'
C:\Users\Dylan\AppData\Local\Temp\cciCuMP6.o:firstProg.c:(.text+0x66): undefined
reference to `_imp__glClear'
C:\Users\Dylan\AppData\Local\Temp\cciCuMP6.o:firstProg.c:(.text+0x74): undefined
reference to `_imp__glBegin'
C:\Users\Dylan\AppData\Local\Temp\cciCuMP6.o:firstProg.c:(.text+0x8c): undefined
reference to `_imp__glVertex2f'
C:\Users\Dylan\AppData\Local\Temp\cciCuMP6.o:firstProg.c:(.text+0xa4): undefined
reference to `_imp__glVertex2f'
C:\Users\Dylan\AppData\Local\Temp\cciCuMP6.o:firstProg.c:(.text+0xbc): undefined
reference to `_imp__glVertex2f'
C:\Users\Dylan\AppData\Local\Temp\cciCuMP6.o:firstProg.c:(.text+0xd4): undefined
reference to `_imp__glVertex2f'
C:\Users\Dylan\AppData\Local\Temp\cciCuMP6.o:firstProg.c:(.text+0xdb): undefined
reference to `_imp__glEnd'
C:\Users\Dylan\AppData\Local\Temp\cciCuMP6.o:firstProg.c:(.text+0xe2): undefined
reference to `_imp__glFlush'
C:\Users\Dylan\AppData\Local\Temp\cciCuMP6.o:firstProg.c:(.text+0x11f): undefine
d reference to `glutDisplayFunc'
C:\Users\Dylan\AppData\Local\Temp\cciCuMP6.o:firstProg.c:(.text+0x124): undefine
d reference to `glutMainLoop'
c:/mingw/bin/../lib/gcc/mingw32/4.8.1/../../../../mingw32/bin/ld.exe: C:\Users\D
ylan\AppData\Local\Temp\cciCuMP6.o: bad reloc address 0x20 in section `.eh_frame
'
c:/mingw/bin/../lib/gcc/mingw32/4.8.1/../../../../mingw32/bin/ld.exe: final link
failed: Invalid operation
collect2.exe: error: ld returned 1 exit status


Anyone here have any idea how to solve these errors? I've tried uninstalling and reinstalling MinGW as well as placing the GLUT files within the required directories again but to no avail.


Thank you in advance, if any further details are required I would be happy to edit the original post.


Aucun commentaire:

Enregistrer un commentaire