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() {
    glClear(GL_COLOR_BUFFER_BIT);
    glFlush();
}
int main(int argc, char **argv) {
    glutInit(&argc, argv);
    glutInitWindowSize(512,512);
    glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB);
    glutCreateWindow("Test Program :: hello world");
    glutDisplayFunc(display);
    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
belajar1.cpp:17:3: warning: no newline at end of file
Linking...
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)

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

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.