# \[Dev C++\] First Test to OpenGL, error found...

**URL:** <https://community.khronos.org/t/dev-c-first-test-to-opengl-error-found/76785>\
**Category:** OpenGL: Basic Coding\
**Created:** [May 7, 2018, 2:18am UTC](https://community.khronos.org/t/dev-c-first-test-to-opengl-error-found/76785 "2018-05-07T02:18:38Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![JamieVanCadsand](https://community.khronos.org/letter_avatar_proxy/v4/letter/j/b782af/32.png) [@JamieVanCadsand](https://community.khronos.org/u/JamieVanCadsand)\
**Post date:** [May 7, 2018, 2:18am UTC](https://community.khronos.org/t/dev-c-first-test-to-opengl-error-found/76785/1 "2018-05-07T02:18:38Z")

</div>

Hey OpenGL Programmers and C++ Users…

I am new with OpenGL and this OpenGL Forum yet…

So i use Dev C++ and i get installed FreeGLUT on Windows XP (at home i work on windows 7 and 10)…  
Now i try if opengl works on Dev C++, but no… i get an error!..

Just this is my script copied from google yet…

```auto
#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();
    return 0;
}

```

Now i get an error in the returning function, so this is the error i get:

> ## Compiling single file…
> 
> - Filename: C:\Documents and Settings\Eigenaar\Bureaublad\GLUT Test.cpp
> - Compiler Name: TDM-GCC 4.9.2 32-bit Release
> 
> ## Processing C++ source file…
> 
> - C++ Compiler: C:\Program Files\Dev-Cpp\MinGW64\bin\g++.exe
> - Command: g++.exe “C:\Documents and Settings\Eigenaar\Bureaublad\GLUT Test.cpp” -o “C:\Documents and Settings\Eigenaar\Bureaublad\GLUT Test.exe” -m32 -I"C:\Program Files\Dev-Cpp\MinGW64\include" -I"C:\Program Files\Dev-Cpp\MinGW64\x86\_64-w64-mingw32\include" -I"C:\Program Files\Dev-Cpp\MinGW64\lib\gcc\x86\_64-w64-mingw32\4.9.2\include" -I"C:\Program Files\Dev-Cpp\MinGW64\lib\gcc\x86\_64-w64-mingw32\4.9.2\include\c++" -L"C:\Program Files\Dev-Cpp\MinGW64\lib32" -L"C:\Program Files\Dev-Cpp\MinGW64\x86\_64-w64-mingw32\lib32" -static-libgcc -m32  
> C:\DOCUME~1\Eigenaar\LOCALS~1\Temp\ccDvQv6O.o:GLUT Test.cpp:(.text+0x1c): undefined reference to `_imp ____ glutInitWithExit@12' C:\DOCUME~1\Eigenaar\LOCALS~1\Temp\ccDvQv6O.o:GLUT Test.cpp:(.text+0x3e): undefined reference to `\_imp\_\_\_\_glutCreateWindowWithExit@8’  
> C:\DOCUME~1\Eigenaar\LOCALS~1\Temp\ccDvQv6O.o:GLUT Test.cpp:(.text+0x60): undefined reference to `_imp ____ glutCreateMenuWithExit@8' C:\DOCUME~1\Eigenaar\LOCALS~1\Temp\ccDvQv6O.o:GLUT Test.cpp:(.text+0x7b): undefined reference to `\_imp\_\_glClear@4’  
> C:\DOCUME~1\Eigenaar\LOCALS~1\Temp\ccDvQv6O.o:GLUT Test.cpp:(.text+0x8c): undefined reference to `_imp__glBegin@4' C:\DOCUME~1\Eigenaar\LOCALS~1\Temp\ccDvQv6O.o:GLUT Test.cpp:(.text+0xb0): undefined reference to `\_imp\_\_glVertex3f@12’  
> C:\DOCUME~1\Eigenaar\LOCALS~1\Temp\ccDvQv6O.o:GLUT Test.cpp:(.text+0xd4): undefined reference to `_imp__glVertex3f@12' C:\DOCUME~1\Eigenaar\LOCALS~1\Temp\ccDvQv6O.o:GLUT Test.cpp:(.text+0xf8): undefined reference to `\_imp\_\_glVertex3f@12’  
> C:\DOCUME~1\Eigenaar\LOCALS~1\Temp\ccDvQv6O.o:GLUT Test.cpp:(.text+0x11c): undefined reference to `_imp__glVertex3f@12' C:\DOCUME~1\Eigenaar\LOCALS~1\Temp\ccDvQv6O.o:GLUT Test.cpp:(.text+0x126): undefined reference to `\_imp\_\_glEnd@0’  
> C:\DOCUME~1\Eigenaar\LOCALS~1\Temp\ccDvQv6O.o:GLUT Test.cpp:(.text+0x12d): undefined reference to `_imp__glFlush@0' C:\DOCUME~1\Eigenaar\LOCALS~1\Temp\ccDvQv6O.o:GLUT Test.cpp:(.text+0x168): undefined reference to `\_imp\_\_glutInitDisplayMode@4’  
> C:\DOCUME~1\Eigenaar\LOCALS~1\Temp\ccDvQv6O.o:GLUT Test.cpp:(.text+0x181): undefined reference to `_imp__glutInitWindowSize@8' C:\DOCUME~1\Eigenaar\LOCALS~1\Temp\ccDvQv6O.o:GLUT Test.cpp:(.text+0x19a): undefined reference to `\_imp\_\_glutInitWindowPosition@8’  
> C:\DOCUME~1\Eigenaar\LOCALS~1\Temp\ccDvQv6O.o:GLUT Test.cpp:(.text+0x1ba): undefined reference to `_imp__glutDisplayFunc@4' C:\DOCUME~1\Eigenaar\LOCALS~1\Temp\ccDvQv6O.o:GLUT Test.cpp:(.text+0x1c4): undefined reference to `\_imp\_\_glutMainLoop@0’  
> collect2.exe: error: ld returned 1 exit status
> 
> ## Compilation results…
> 
> - Errors: 1
> - Warnings: 0
> - Compilation Time: 1,17s

I am an newbie with OpenGL and i use Dev C++ for it…, Please can anyone help me to correct my code ?..  
Thanks for help, Jamie.

---

<div class="post-metadata">

**Author:** ![Dark\_Photon](https://community.khronos.org/user_avatar/community.khronos.org/dark_photon/32/4349_2.png) [@Dark\_Photon](https://community.khronos.org/u/Dark_Photon)\
**Post date:** [May 7, 2018, 4:53am UTC](https://community.khronos.org/t/dev-c-first-test-to-opengl-error-found/76785/2 "2018-05-07T04:53:21Z")

</div>

Your link line is missing references to the GLUT and OpenGL libraries.

Try adding the arguments “-lglut32 -lopengl32”. If you still have unresolved “glut” symbols", try -lfreeglut instead of -lglut32.

For more possible solutions, websearch “devc++ glut unresolved reference”. For instance:

[ul]  
[li][Undefined references using GLUT with MinGW](https://stackoverflow.com/questions/14411960/undefined-references-using-glut-with-mingw)  
[/li][/ul]
