Linking Error (New to GLUT)

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 est.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.


void display(void) {
glColor3f(1.0, 1.0, 1.0);
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);

void init(void) {
glClearColor(0.0, 0.0, 0.0, 0.0);
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);
return 0;

Don’t include <windows.h> or try to have a new .lib file.

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.

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).]

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:

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 ?


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:
I think this a little different version of GLUT so I am not sure if you also must update glut32.lib

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 Any pointers ???

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…