PDA

View Full Version : Clear Step by Step Process for using GLUT with Dev-CPP Required



Suddhasheel
06-05-2005, 08:44 AM
I was trying to use GLUT with Dev-CPP. It seems it does not work bcos the linker is giving some undefined references error.

Please provide help.

Regards and thanks in advance.

UrbanLegend
06-05-2005, 09:20 AM
it might help if you actually post the linker's error messages

Suddhasheel
06-05-2005, 07:42 PM
For example I used

glClearColor(1,0,0,1);

The linker gives undefined reference to

__imp__glClearColor.......

!!!! :confused: :eek:

Suddhasheel
06-05-2005, 07:44 PM
I have used the line

#include <GL\glut.h>

and completed the neccessary formalities of copying the library files and dll files to the necessary places.

Do I need to locally compile again.... ????

Suddhasheel
06-05-2005, 09:09 PM
Here are the compiler message while compiling
Executing g++.exe...
g++.exe "D:\shudh\ccodes\ogl_vertex_data\ogl_vertex_data\te st.cpp" -o "D:\shudh\ccodes\ogl_vertex_data\ogl_vertex_data\te st.exe" -I"C:\apps\Dev-Cpp\lib\gcc\mingw32\3.4.2\include" -I"C:\apps\Dev-Cpp\include\c++\3.4.2\backward" -I"C:\apps\Dev-Cpp\include\c++\3.4.2\mingw32" -I"C:\apps\Dev-Cpp\include\c++\3.4.2" -I"C:\apps\Dev-Cpp\include" -L"C:\apps\Dev-Cpp\lib" -lglu32
C:\DOCUME~1\SUDDHA~1\LOCALS~1\Temp/cc4cbaaa.o(.text+0x2a):test.cpp: undefined reference to `glClearColor@16'
C:\DOCUME~1\SUDDHA~1\LOCALS~1\Temp/cc4cbaaa.o(.text+0x55):test.cpp: undefined reference to `glOrtho@48'
C:\DOCUME~1\SUDDHA~1\LOCALS~1\Temp/cc4cbaaa.o(.text+0x6c):test.cpp: undefined reference to `glClear@4'
C:\DOCUME~1\SUDDHA~1\LOCALS~1\Temp/cc4cbaaa.o(.text+0x74):test.cpp: undefined reference to `glFlush@0'
C:\DOCUME~1\SUDDHA~1\LOCALS~1\Temp/cc4cbaaa.o(.text+0xb2):test.cpp: undefined reference to `glutInit'
C:\DOCUME~1\SUDDHA~1\LOCALS~1\Temp/cc4cbaaa.o(.text+0xbe):test.cpp: undefined reference to `glutInitDisplayMode'
C:\DOCUME~1\SUDDHA~1\LOCALS~1\Temp/cc4cbaaa.o(.text+0xd2):test.cpp: undefined reference to `glutInitWindowSize'
C:\DOCUME~1\SUDDHA~1\LOCALS~1\Temp/cc4cbaaa.o(.text+0xe6):test.cpp: undefined reference to `glutInitWindowPosition'
C:\DOCUME~1\SUDDHA~1\LOCALS~1\Temp/cc4cbaaa.o(.text+0xf2):test.cpp: undefined reference to `glutCreateWindow'
C:\DOCUME~1\SUDDHA~1\LOCALS~1\Temp/cc4cbaaa.o(.text+0x103):test.cpp: undefined reference to `glutDisplayFunc'

C:\DOCUME~1\SUDDHA~1\LOCALS~1\Temp/cc4cbaaa.o(.text+0x108):test.cpp: undefined reference to `glutMainLoop'
collect2: ld returned 1 exit status

Execution terminated

Silkut
06-06-2005, 12:54 AM
You should link the libraries with Dev-Cpp, this IDE's using MingW compiler (which is a winport of Gcc\un!x)

you should link libs like you linked glu library, for opengl lib and glut lib, because glut != opengl
-lgl -> opengl lib
-lglu32 -> glu lib // you linked that
-lglut -> glut lib
-lwhat_you_want -> what you want lib

hope that helps

Suddhasheel
06-06-2005, 05:12 AM
Ya I compiled with Dev-CPP only which works on MingW32.

Unfortunately that -lgl option is not working .... !!!

That means I should have a file name libgl.a or something... Where can I get that file ????

Please help..

Suddhasheel
06-07-2005, 07:53 PM
Help this the code and it is not working
#include <windows.h>
#include <GL\glut.h>

void init()
{
glClearColor(1,0,0,1);
glOrtho(0,1,0,1,0,1);
}

void display()
{
glClear(GL_COLOR_BUFFER_BIT);
glFlush();
}

int main(int argc, char **argv)
{
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_RGB|GLUT_SINGLE);
glutInitWindowSize(800,600);
glutInitWindowPosition(5,20);
glutCreateWindow("Tutorial 1");
init();
glutDisplayFunc(display);
glutMainLoop();
return 0;
}

The error messages given by the compiler are as follows:

g++.exe "D:\shudh\ccodes\ogl_vertex_data\ogl_vertex_data\te st.cpp" -o "D:\shudh\ccodes\ogl_vertex_data\ogl_vertex_data\te st.exe" -I"C:\apps\Dev-Cpp\lib\gcc\mingw32\3.4.2\include" -I"C:\apps\Dev-Cpp\include\c++\3.4.2\backward" -I"C:\apps\Dev-Cpp\include\c++\3.4.2\mingw32" -I"C:\apps\Dev-Cpp\include\c++\3.4.2" -I"C:\apps\Dev-Cpp\include" -L"C:\apps\Dev-Cpp\lib" -lglu32 -lopengl32 -lglut -mwindows
C:\DOCUME~1\SUDDHA~1\LOCALS~1\Temp/cce6aaaa.o(.text+0xb2):test.cpp: undefined reference to `glutInit'
C:\DOCUME~1\SUDDHA~1\LOCALS~1\Temp/cce6aaaa.o(.text+0xbe):test.cpp: undefined reference to `glutInitDisplayMode'
C:\DOCUME~1\SUDDHA~1\LOCALS~1\Temp/cce6aaaa.o(.text+0xd2):test.cpp: undefined reference to `glutInitWindowSize'
C:\DOCUME~1\SUDDHA~1\LOCALS~1\Temp/cce6aaaa.o(.text+0xe6):test.cpp: undefined reference to `glutInitWindowPosition'
C:\DOCUME~1\SUDDHA~1\LOCALS~1\Temp/cce6aaaa.o(.text+0xf2):test.cpp: undefined reference to `glutCreateWindow'
C:\DOCUME~1\SUDDHA~1\LOCALS~1\Temp/cce6aaaa.o(.text+0x103):test.cpp: undefined reference to `glutDisplayFunc'
C:\DOCUME~1\SUDDHA~1\LOCALS~1\Temp/cce6aaaa.o(.text+0x108):test.cpp: undefined reference to `glutMainLoop'
collect2: ld returned 1 exit status

Execution terminated