I'm a student working with OpenGL in C++. I'm trying to get freeGLUT to work with MinGW. I'm asking because I've already tried a ton of sites, multiple times and there is no clear solution, at least to my knowledge. I've had this problem for months.
Although using Visual Studio would be the simplest environment to use, I'd prefer to use my own customized environment.
The issue I'm having is the linker. I'm having great difficulty understanding as a newer user how to use the linker.
My main goal is simply to compile any basic program, for example, this test one:
#include <GL/glut.h>
void displayMe(void)
{
glClear(GL_COLOR_BUFFER_BIT);
glBegin(GL_POLYGON);
glVertex3f(0.0, 0.0, 0.0);
glVertex3f(0.5, 0.0, 0.0);
glVertex3f(0.5, 0.5, 0.0);
glVertex3f(0.0, 0.5, 0.0);
glEnd();
glFlush();
}
int main(int argc, char** argv)
{
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_SINGLE);
glutInitWindowSize(300, 300);
glutInitWindowPosition(100, 100);
glutCreateWindow("Hello world :D");
glutDisplayFunc(displayMe);
glutMainLoop();
re
turn 0;
}
Here are my linker errors:
> C:\Users\Exhuman\AppData\Local\Temp\ccM8iHrk.o:main.cpp:(.text+0x25):
> undefined reference to `__imp___glutInitWithExit'
> C:\Users\Exhuman\AppData\Local\Temp\ccM8iHrk.o:main.cpp:(.text+0x4c):
> undefined reference to `__imp___glutCreateWindowWithExit'
> C:\Users\Exhuman\AppData\Local\Temp\ccM8iHrk.o:main.cpp:(.text+0x72):
> undefined reference to `__imp___glutCreateMenuWithExit'
> C:\Users\Exhuman\AppData\Local\Temp\ccM8iHrk.o:main.cpp:(.text+0x8e):
> undefined reference to `__imp_glClear'
> C:\Users\Exhuman\AppData\Local\Temp\ccM8iHrk.o:main.cpp:(.text+0x9c):
> undefined reference to `__imp_glBegin'
> C:\Users\Exhuman\AppData\Local\Temp\ccM8iHrk.o:main.cpp:(.text+0xb1):
> undefined reference to `__imp_glVertex3f'
> C:\Users\Exhuman\AppData\Local\Temp\ccM8iHrk.o:main.cpp:(.text+0xca):
> undefined reference to `__imp_glVertex3f'
> C:\Users\Exhuman\AppData\Local\Temp\ccM8iHrk.o:main.cpp:(.text+0xe7):
> undefined reference to `__imp_glVertex3f'
> C:\Users\Exhuman\AppData\Local\Temp\ccM8iHrk.o:main.cpp:(.text+0x100):
> undefined reference to `__imp_glVertex3f'
> C:\Users\Exhuman\AppData\Local\Temp\ccM8iHrk.o:main.cpp:(.text+0x109):
> undefined reference to `__imp_glEnd'
> C:\Users\Exhuman\AppData\Local\Temp\ccM8iHrk.o:main.cpp:(.text+0x112):
> undefined reference to `__imp_glFlush'
> C:\Users\Exhuman\AppData\Local\Temp\ccM8iHrk.o:main.cpp:(.text+0x14b):
> undefined reference to `__imp_glutInitDisplayMode'
> C:\Users\Exhuman\AppData\Local\Temp\ccM8iHrk.o:main.cpp:(.text+0x15e):
> undefined reference to `__imp_glutInitWindowSize'
> C:\Users\Exhuman\AppData\Local\Temp\ccM8iHrk.o:main.cpp:(.text+0x171):
> undefined reference to `__imp_glutInitWindowPosition'
> C:\Users\Exhuman\AppData\Local\Temp\ccM8iHrk.o:main.cpp:(.text+0x18d):
> undefined reference to `__imp_glutDisplayFunc'
> C:\Users\Exhuman\AppData\Local\Temp\ccM8iHrk.o:main.cpp:(.text+0x196):
> undefined reference to `__imp_glutMainLoop' collect2.exe: error: ld
> returned 1 exit status
I'm including a download link to my custom working environment as I feel it would be too time consuming to set up, the components are MinGW, Notepad++ and NppExec programs can be compiled with "f9" if there are no errors, and similarly can be run with "ctrl f9" once compiled. I usually run the program using the .bat in the main directory.
http://www.filedropper.com/env_1
If anyone could help me out with this issue, I'd greatly appreciate it.
What I have tried:
This site: http://www.transmissionzero.co.uk/computing/using-glut-with-mingw/ was the closest I found, and I tried to contact the author for a solution and so far he has been unresponsive.
I also tried to look up MinGW and the linker, but the jargon is outwith my comprehension.