PDA

View Full Version : glut undefined?



oGL_nEwB
02-03-2004, 03:56 PM
lol now i have yet another error in devcpp
after i have linked -lopengl32 -lglu32
-lglut32. It says as a linker error this:

"c:\documents and settings\dylan snowden\desktop\my stuff\my c++\open gl\my opengl\glcode.o(.text+0x17):glcode.cpp: undefined reference to `__glutInitWithExit@12'
c:\documents and settings\dylan snowden\desktop\my stuff\my c++\open gl\my opengl\glcode.o(.text+0x3b):glcode.cpp: undefined reference to `__glutCreateWindowWithExit@8'
c:\documents and settings\dylan snowden\desktop\my stuff\my c++\open gl\my opengl\glcode.o(.text+0x67):glcode.cpp: undefined reference to `__glutCreateMenuWithExit@8'"


"c:\documents and settings\dylan snowden\desktop\my stuff\my c++\open gl\my opengl\glcode.o(.text+0x17):glcode.cpp: undefined reference to `__glutInitWithExit@12'
c:\documents and settings\dylan snowden\desktop\my stuff\my c++\open gl\my opengl\glcode.o(.text+0x3b):glcode.cpp: undefined reference to `__glutCreateWindowWithExit@8'
c:\documents and settings\dylan snowden\desktop\my stuff\my c++\open gl\my opengl\glcode.o(.text+0x67):glcode.cpp: undefined reference to `__glutCreateMenuWithExit@8'"


"c:\documents and settings\dylan snowden\desktop\my stuff\my c++\open gl\my opengl\glcode.o(.text+0x17):glcode.cpp: undefined reference to `__glutInitWithExit@12'
c:\documents and settings\dylan snowden\desktop\my stuff\my c++\open gl\my opengl\glcode.o(.text+0x3b):glcode.cpp: undefined reference to `__glutCreateWindowWithExit@8'
c:\documents and settings\dylan snowden\desktop\my stuff\my c++\open gl\my opengl\glcode.o(.text+0x67):glcode.cpp: undefined reference to `__glutCreateMenuWithExit@8'"


Geez i have one thing after the next...
and i have all the files in the right folders.

chowe6685
02-03-2004, 04:50 PM
#define GLUT_DISABLE_ATEXIT_HACK

nexusone
02-04-2004, 04:06 AM
Need to see your code in order to say what you are doing wrong.




[This message has been edited by nexusone (edited 02-04-2004).]

oGL_nEwB
02-04-2004, 11:02 AM
ok i have dled the nehe 1st tutorial... for glut based and i have tried to compile it in devcpp and those are the errors i get. i have dled also the glut libraries and the dlls and so on...

here is the code


/*
NeHe (nehe.gamedev.net) OpenGL tutorial series
GLUT port.in 2001 by milix (milix_gr@hotmail.com)
Most comments are from the original tutorials found in NeHe.
For VC++ users, create a Win32 Console project and link
the program with glut32.lib, glu32.lib, opengl32.lib
*/

#include <windows.h> // Standard Header For MSWindows Applications
#include <gl/glut.h> // The GL Utility Toolkit (GLUT) Header

// The Following Directive Fixes The Problem With Extra Console Window
#pragma comment(linker, "/subsystem:\"windows\" /entry:\"mainCRTStartup\"")

// Global Variables
bool g_gamemode; // GLUT GameMode ON/OFF
bool g_fullscreen; // Fullscreen Mode ON/OFF (When g_gamemode Is OFF)

// Our GL Specific Initializations
bool init(void)
{
glShadeModel(GL_SMOOTH); // Enable Smooth Shading
glClearColor(0.0f, 0.0f, 0.0f, 0.5f); // Black Background
glClearDepth(1.0f); // Depth Buffer Setup
glEnable(GL_DEPTH_TEST); // Enables Depth Testing
glDepthFunc(GL_LEQUAL); // The Type Of Depth Testing To Do
glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST); // Really Nice Perspective Calculations
return true;
}

// Our Rendering Is Done Here
void render(void)
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // Clear Screen And Depth Buffer
glLoadIdentity(); // Reset The Current Modelview Matrix

// Swap The Buffers To Become Our Rendering Visible
glutSwapBuffers ( );
}

// Our Reshaping Handler (Required Even In Fullscreen-Only Modes)
void reshape(int w, int h)
{
glViewport(0, 0, w, h);
glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
glLoadIdentity(); // Reset The Projection Matrix
// Calculate The Aspect Ratio And Set The Clipping Volume
if (h == 0) h = 1;
gluPerspective(80, (float)w/(float)h, 1.0, 5000.0);
glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
glLoadIdentity(); // Reset The Modelview Matrix
}

// Our Keyboard Handler (Normal Keys)
void keyboard(unsigned char key, int x, int y)
{
switch (key) {
case 27: // When Escape Is Pressed...
exit(0); // Exit The Program
break; // Ready For Next Case
default: // Now Wrap It Up
break;
}
}

// Our Keyboard Handler For Special Keys (Like Arrow Keys And Function Keys)
void special_keys(int a_keys, int x, int y)
{
switch (a_keys) {
case GLUT_KEY_F1:
// We Can Switch Between Windowed Mode And Fullscreen Mode Only
if (!g_gamemode) {
g_fullscreen = !g_fullscreen; // Toggle g_fullscreen Flag
if (g_fullscreen) glutFullScreen(); // We Went In Fullscreen Mode
else glutReshapeWindow(500, 500); // We Went In Windowed Mode
}
break;
default:
break;
}
}

// Ask The User If He Wish To Enter GameMode Or Not
void ask_gamemode()
{
int answer;
// Use Windows MessageBox To Ask The User For Game Or Windowed Mode
answer = MessageBox(NULL, "Do you want to enter game mode?", "Question",
MB_ICONQUESTION | MB_YESNO);
g_gamemode = (answer == IDYES);
// If Not Game Mode Selected, Use Windowed Mode (User Can Change That With F1)
g_fullscreen = false;
}

// Main Function For Bringing It All Together.
int main(int argc, char** argv)
{
ask_gamemode(); // Ask For Fullscreen Mode
glutInit(&amp;argc, argv); // GLUT Initializtion
glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE); // Display Mode (Rgb And Double Buffered)
if (g_gamemode) {
glutGameModeString("640x480:16"); // Select The 640x480 In 16bpp Mode
if (glutGameModeGet(GLUT_GAME_MODE_POSSIBLE))
glutEnterGameMode(); // Enter Full Screen
else g_gamemode = false; // Cannot Enter Game Mode, Switch To Windowed
}
if (!g_gamemode) {
glutInitWindowSize(500, 500); // Window Size If We Start In Windowed Mode
glutCreateWindow("NeHe's OpenGL Framework"); // Window Title
}
init(); // Our Initialization
glutDisplayFunc(render); // Register The Display Function
glutReshapeFunc(reshape); // Register The Reshape Handler
glutKeyboardFunc(keyboard); // Register The Keyboard Handler
glutSpecialFunc(special_keys); // Register Special Keys Handler
glutMainLoop(); // Go To GLUT Main Loop
return 0;
}

well?
o and this is with the newer devcpp

nexusone
02-04-2004, 11:16 AM
How did you setup the project?
As a windows application or console?
Also did you select C or C++ option?

If you create is as a windows program, you may need to live this bit of code out on DEV-C++

#pragma comment(linker, "/subsystem:\"windows\" /entry:\"mainCRTStartup\"")

oGL_nEwB
02-04-2004, 12:08 PM
nope it didnt work..
now that im usin the new devcpp i have these errors

"

[Linker error] undefined reference to `__glutInitWithExit@12'

[Linker error] undefined reference to `__glutCreateWindowWithExit@8'


[Linker error] undefined reference to `__glutCreateMenuWithExit@8'

[Linker error] undefined reference to `glShadeModel@4'

[Linker error] undefined reference to `glClearColor@16'

[Linker error] undefined reference to `glClearDepth@8'

[Linker error] undefined reference to `glEnable@4'

[Linker error] undefined reference to `glDepthFunc@4'

[Linker error] undefined reference to `glHint@8'

[Linker error] undefined reference to `glClear@4'

[Linker error] undefined reference to `glLoadIdentity@0'

[Linker error] undefined reference to `glutSwapBuffers@0'

[Linker error] undefined reference to `glViewport@16'

[Linker error] undefined reference to `glMatrixMode@4'

[Linker error] undefined reference to `glLoadIdentity@0'

[Linker error] undefined reference to `gluPerspective@32'

[Linker error] undefined reference to `glMatrixMode@4'

[Linker error] undefined reference to `glLoadIdentity@0'

[Linker error] undefined reference to `glutFullScreen@0'

[Linker error] undefined reference to `glutReshapeWindow@8'

[Linker error] undefined reference to `glutInitDisplayMode@4'

[Linker error] undefined reference to `glutGameModeString@4'

[Linker error] undefined reference to `glutGameModeGet@4'

[Linker error] undefined reference to `glutEnterGameMode@0'

[Linker error] undefined reference to `glutInitWindowSize@8'

[Linker error] undefined reference to `glutDisplayFunc@4'

[Linker error] undefined reference to `glutReshapeFunc@4'

[Linker error] undefined reference to `glutKeyboardFunc@4'

[Linker error] undefined reference to `glutSpecialFunc@4'

[Linker error] undefined reference to `glutMainLoop@0' "

ok lol i think it deffinately has sumtin to do with headers or the dll's but see in devcpp 5 i havnt seen one GL dll in the directories of devcpp except 2 for like c++

am i missin sumtin?

soft peach
02-04-2004, 01:16 PM
[QUOTE]Originally posted by oGL_nEwB:
now that im usin the new devcpp i have these errors

"

[Linker error] undefined reference to `__glutInitWithExit@12'

[Linker error] undefined reference to `__glutCreateWindowWithExit@8'

-------------------------

try adding a

#define GLUT_DISABLE_ATEXIT_HACK

just before your include to gl/glut.h

I had the same problem as you with devcpp, and this #define solved mine.


[This message has been edited by soft peach (edited 02-04-2004).]

oGL_nEwB
02-05-2004, 05:19 AM
lol
ok that solved the exit problem ...
lol but now i have these errors. some of the glut functions arent working like glutCreateWindow and some of the gl's arent working... here are the errors....
(i am also using the nehe glut based code to compile and it still doesnt work)


[Linker error] undefined reference to `glShadeModel@4'

[Linker error] undefined reference to `glClearColor@16'

[Linker error] undefined reference to `glClearDepth@8'

[Linker error] undefined reference to `glEnable@4'

[Linker error] undefined reference to `glDepthFunc@4'

[Linker error] undefined reference to `glHint@8'

[Linker error] undefined reference to `glClear@4'

[Linker error] undefined reference to `glLoadIdentity@0'

[Linker error] undefined reference to `glutSwapBuffers@0'

[Linker error] undefined reference to `glViewport@16'

[Linker error] undefined reference to `glMatrixMode@4'

[Linker error] undefined reference to `glLoadIdentity@0'

[Linker error] undefined reference to `gluPerspective@32'

[Linker error] undefined reference to `glMatrixMode@4'

[Linker error] undefined reference to `glLoadIdentity@0'

[Linker error] undefined reference to `glutFullScreen@0'

[Linker error] undefined reference to `glutReshapeWindow@8'

[Linker error] undefined reference to `glutInit@8'

[Linker error] undefined reference to `glutInitDisplayMode@4'

[Linker error] undefined reference to `glutGameModeString@4'

[Linker error] undefined reference to `glutGameModeGet@4'

[Linker error] undefined reference to `glutEnterGameMode@0'

[Linker error] undefined reference to `glutInitWindowSize@8'

[Linker error] undefined reference to `glutCreateWindow@4'

[Linker error] undefined reference to `glutDisplayFunc@4'

[Linker error] undefined reference to `glutReshapeFunc@4'

[Linker error] undefined reference to `glutKeyboardFunc@4'

[Linker error] undefined reference to `glutSpecialFunc@4'

[Linker error] undefined reference to `glutMainLoop@0'

almost as if it isnt reading the glut and gl library files... but like i said before i have not seen one dll for gl glut or glu. does devcpp 5 already link them or somethin?

theUnknowing
02-05-2004, 05:30 AM
Well, it's probably not the same problem, but the first thing I do when I get a slew of similar type errors, I check to make sure my Library files are properly set up. Using Visual C++, I check under Project->Settings, and hit the Link tab. For almost any file in my 'Include' headers, I make sure I have the right '.lib' file listed.

For example, for #include <gl/gl.h> I make sure I have 'opengl32.lib' referenced. For GLUT, it needs 'glut32.lib', etc.

You've probably checked all this out already, but it never hurts to double-check.

theUnknowing
02-05-2004, 05:39 AM
Or there's another possibility. You made reference to not being able to find .dll files... installing OpenGL provides you with the .dll files you need, but it doesn't necessarily put them anywhere where they'd be easy to get at. You'd have to setup your development software to look in the directory where the files are kept. Or (and this is what I do to prevent any doubt), I simply take the important dll files (glut32.dll, opengl32.dll, etc), and copy them into my Windows/System folder. No muss, no fuss.

If you installed OpenGL correctly, the .dll's ARE there... somewhere. http://www.opengl.org/discussion_boards/ubb/smile.gif

nexusone
02-05-2004, 07:55 AM
Did you put the -lopengl32 -lglu32 -lglut32 in the correct location in the linker options?

Also are you using the openGL librarys supplied with DEV-C++?