PDA

View Full Version : Linking Error (New to GLUT)



phunq
02-17-2001, 06:11 AM
Could anyone tell me what the problem is with the following code, I have just installed Borland C++ v5 and installed the GLUT libraries but I get this error : -

Info :Linking C:\Projects\test.exe
Error: Error: 'C:\BC5\LIB\GLUT32.LIB' contains invalid OMF record, type 0x21

The program I have used is from the red OpenGL programming Guide by Mason Woo. Any help would be appreciated.

#include<windows.h>
#include<gl\glut.h>
#include<stdio.h>
#include<stdlib.h>

void display(void) {
glClear(GL_COLOR_BUFFER_BIT);
glColor3f(1.0, 1.0, 1.0);
glBegin(GL_POLYGON);
glVertex3f(0.25, 0.25, 0.0);
glVertex3f(0.75, 0.25, 0.0);
glVertex3f(0.75, 0.75, 0.0);
glVertex3f(0.25, 0.75, 0.0);
glEnd();
glFlush();
}

void init(void) {
glClearColor(0.0, 0.0, 0.0, 0.0);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(0.0, 1.0, 0.0, 1.0, -1.0, 1.0);
}

int main(int argc, char** argv) {
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB);
glutInitWindowSize(250, 250);
glutInitWindowPosition(100, 100);
glutCreateWindow("Square");
init();
glutDisplayFunc(display);
glutMainLoop();
return 0;
}

Leyder Dylan
02-17-2001, 08:44 AM
Don't include <windows.h> or try to have a new .lib file.

phunq
02-17-2001, 08:48 AM
I have had a new version of the .lib file sent to me from someone who has tried it and it works on their machine and removed the windows.h but still no joy.

Deiussum
02-17-2001, 09:44 AM
Well, it appears to be a linker error not a compiler error so it's probably something with your library. Are you sure the library you were sent is compatible with Borland? VC++ and Borland use different formats for their libraries.

[This message has been edited by Deiussum (edited 02-17-2001).]

mango
02-17-2001, 04:22 PM
Yes, the most likely explanation is that the glut32.lib is for msvc coff2omf should be able to convert it. If you are planning to use glut in c++ programs do you also need a modified header. Borland has problems with the exit stuff.

A modified header and libraries is available among other places at: http://sites.netscape.net/ptrpck/borland.htm

phunq
02-17-2001, 05:25 PM
Getting there, the error has gone with the libraries but I am getting the exit problem you mentioned even after downloading the new header file for it. Does anyone have a copy they can mail me ?

Thanks,
Brian

mango
02-18-2001, 05:09 PM
You can try to define GLUT_DISABLE_ATEXIT_HACK before including glut.h, check the header for the correct name. Strange that the header did not allow C++ but perhaps is it some difference between Borland compilers.

An alternative could be to download a new header, here is one example: http://www.gnt.net/~heiman/
I think this a little different version of GLUT so I am not sure if you also must update glut32.lib

phunq
02-19-2001, 03:23 AM
The Saga Continues.....

I updated again and the EXIT problem is gone but now it compiles and pops up a a dialog box with
"You have accidentally used the dummy version of OwlMain."

I do not understand this at all http://www.opengl.org/discussion_boards/ubb/confused.gif Any pointers ???

mango
02-19-2001, 06:44 PM
GLUT is doing some hacks with the main/WinMain functions and can be difficult to combine with other libraries. If you are including any OWL headers so try to remove them. Or perhaps is it about how the program is linked?

The easy solution is to have one C file with the GLUT stuff and use C++ in the other source files. Another option is of course to download the free compiler...