Search code examples
copengllinkerglutmingw-w64

Mingw w64's linker skipping incompatible when searching for -lglut32 new


I am trying to compile this simple C/OpenGL program with mingw w64

#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;
}

I have downloaded glut.h, libglut32.a and glut32.dll, and placed them in their right path. Especially i put glut32.dll in C:\windows\SysWOW64 folder but when i try compiling with this:

gcc -o test test.c -lglu32 -lopengl32 -lglut32

but it gives me a bunch of errors, so i tried linking only glu32 and opengl32 and it works fine, but when i link glut32 it gives me this:

C:/Program Files/mingw-w64/x86_64-8.1.0-posix-seh-rt_v6-rev0/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: skipping incompatible C:/Program Files/mingw-w64/x86_64-8.1.0-posix-seh-rt_v6-rev0/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/lib/../lib/libglut32.a when searching for -lglut32

I tried searching what the problem could be, and I found that it is an architecture problem, because glut32.dll is a 32 bit library but i couldn't find a glut64.dll library and I don't know what to do.

Any suggestions?

EDIT: I managed to solve my problem, I looked on the internet for glut32.lib and glut64.lib and put them in the lib folder(they were missing in the glutming archive I had downloaded) and downloaded glut64.dll from the internet and now it all works fine.

Thanks everyone


Solution

  • I managed to solve my problem, I looked on the internet for glut32.lib and glut64.lib and put them in the lib folder(they were missing in the glutming archive I had downloaded) and downloaded glut64.dll from the internet and now it all works fine.