Please help me sir.. its my first .. how to instal OpenGL Library into MinGW ....
i have tried but error
code :

#include <GL/gl.h>
#include <GL/glut.h>

void display() {
int main(int argc, char **argv) {
    glutInit(&argc, argv);
    glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB);
    glutCreateWindow("Test Program :: hello world");
    glClearColor(0.0, 0.0, 0.0, 1.0);
    glutMainLoop(); // Infinite event loop
    return 0;

error :

--------------------Configuration: openGL - Debug--------------------
Compiling source file(s)...
belajar1.cpp:17:3: warning: no newline at end of file
C:\MinGWStudio\openGL\Debug\belajar1.o: In function glutInit_ATEXIT_HACK': C:\MinGWStudio\MinGW\bin\..\lib\gcc\mingw32\3.4.5\..\..\..\..\include\GL\glut.h:495: undefined reference to__glutInitWithExit@12'
C:\MinGWStudio\openGL\Debug\belajar1.o: In function glutCreateWindow_ATEXIT_HACK': C:\MinGWStudio\MinGW\bin\..\lib\gcc\mingw32\3.4.5\..\..\..\..\include\GL\glut.h:512: undefined reference to__glutCreateWindowWithExit@8'
C:\MinGWStudio\openGL\Debug\belajar1.o: In function glutCreateMenu_ATEXIT_HACK': C:\MinGWStudio\MinGW\bin\..\lib\gcc\mingw32\3.4.5\..\..\..\..\include\GL\glut.h:558: undefined reference to__glutCreateMenuWithExit@8'
C:\MinGWStudio\openGL\Debug\belajar1.o: In function Z7displayv': C:\MinGWStudio\openGL\belajar1.cpp:5: undefined reference toglClear@4'
C:\MinGWStudio\openGL\belajar1.cpp:6: undefined reference to glFlush@0' C:\MinGWStudio\openGL\Debug\belajar1.o: In functionmain':
C:\MinGWStudio\openGL\belajar1.cpp:10: undefined reference to glutInitWindowSize@8' C:\MinGWStudio\openGL\belajar1.cpp:11: undefined reference toglutInitDisplayMode@4'
C:\MinGWStudio\openGL\belajar1.cpp:13: undefined reference to glutDisplayFunc@4' C:\MinGWStudio\openGL\belajar1.cpp:14: undefined reference toglClearColor@16'
C:\MinGWStudio\openGL\belajar1.cpp:15: undefined reference to `glutMainLoop@0'
collect2: ld returned 1 exit status

openGL.exe - 10 error(s), 1 warning(s)

3 Years
Discussion Span
Last Post by edrianhadinata

belajar1.cpp:17:3: warning: no newline at end of file

Move the cursor to the end of the last line of your program, press the Enter key, then save. Some compilers don't like not having a '\n' at the end of the file.

The other errors are because the program isn't linking with openGL libraries. What IDE (if any) are you using?


Your problem is a linking problem. To use openGL you must not just include the header files, but also link to the OpenGL libraries. If your installation managed to find the OpenGL headers (as it did, since it compiled correctly, just didn't link correctly), then it almost certainly means that the OpenGL libraries (that you need to link to) are also installed.

See this page. What you need to pay attention to is the line that says how to compile a program:

$ gcc -o hello.exe -Wall hello.c glee.lib glut32.lib -lopengl32 -lglu32

As you see, the *.lib and the -l* parts tell the compiler about the libraries that are needed to be linked with your program. If you are using an IDE, then you should look for a configuration option that allows you to enter the names of the additional libraries to link to. In there, you would need to add glee.lib, glut32.lib, libopengl32.a and libglu32.a. That should do the trick. Otherwise, just try to compile in command-line using a command similar to that above (replacing the source-file and executable names with your own).


thanks all.. i tried to copy some instalation files before.. but now i had to do this trick

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.