Quantcast
Channel: Active questions tagged gcc - Stack Overflow
Viewing all articles
Browse latest Browse all 22042

Undefined reference with GLUT for MinGW

$
0
0

Here is my directory:

graphics/
    glut.h
    glut32.dll
    glut32.lib
    simple.c

Here is my program:

#include <windows.h>
#include <GL/gl.h>
#include <GL/glext.h>
#include "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();
}

When I try to compile using the following command

 gcc simple.c -o MyProg glut32.lib -lopengl32 -lglu32

I get the following errors:

C:\Users\Jake\AppData\Local\Temp\ccehzclV.o:simple.c:(.text+0x28): undefined reference to `__imp___glutInitWithExit'
C:\Users\Jake\AppData\Local\Temp\ccehzclV.o:simple.c:(.text+0x52): undefined reference to `__imp___glutCreateWindowWithExit'
C:\Users\Jake\AppData\Local\Temp\ccehzclV.o:simple.c:(.text+0x7b): undefined reference to `__imp___glutCreateMenuWithExit'
C:\Users\Jake\AppData\Local\Temp\ccehzclV.o:simple.c:(.text+0x162): undefined reference to `__imp_glutDisplayFunc'
C:\Users\Jake\AppData\Local\Temp\ccehzclV.o:simple.c:(.text+0x16b): undefined reference to `__imp_glutMainLoop'
collect2.exe: error: ld returned 1 exit status

I've tried every answer I can find, I've reinstalled MinGW, and I've reinstalled tdm-gcc. Nothing has worked, I'm hoping someone can shine some light on this.

EDIT: I've also added glut32.dll to system32 with no luck.


Viewing all articles
Browse latest Browse all 22042

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>