WINGDIAPI variable compilation error

I’m using Borland Turbo C++ 4.5 with OpenGL, Windows98.

I’m getting 26 compilation errors in the include file gl.h (version 37). They’re all the same, “Variable WINGDIAPI is initialized more than once”.

I don’t think anything is wrong with gl.h and I don’t want to touch it. …but I’m not sure what else to do.

I’m really anxious to get started developing my own programs in OpenGL. Anybody’s help would be greatly appreciated.


[This message has been edited by Temo45 (edited 06-01-2002).]

[This message has been edited by Temo45 (edited 06-02-2002).]

Hi !

I am not sure why you get it, but WINGDIAPI is not a variable, it is #define for the function atrributes, like:
void WINGDIAPI glBlaBlaBla() something.

So it sounds like it fails to include windows.h or something like that.


Be sure to include windoze.h before you include glut.h.

Originally posted by rpxmaster:
Be sure to include windoze.h before you include glut.h.


Thanks, windows.h was included already.
I’m wondering if it’s a problem with the settings I’m using on my compiler (Turbo C++ 4.5). I would be interested in comparing my settings with those of others using the same platform. I’d greatly appreciate any advice you have.


Is windows.h included BEFORE gl.h?

If you’re doing this…

#include <GL/gl.h>
#include <windows.h>

You’ll still get those errors, becase gl.h uses stuff defined in windows.h, so windows.h needs to come first.

On 06-01-2002 05:42 PM, a frequent contributor named rpxmaster made the following remark:
Be sure to include windoze.h before you include glut.h.

Like I said, be sure to include windoze.h before you include glut.h.

So, your code should look somewhat like this:

/* Windoze specific header files */

#include <windoze.h>

/* OpenGL specific header files */

#include <gl/gl.h>


>It look’s pretty ok to me, is this the gl.h that was included with the Borland compiler?

I downloaded this gl.h from the website some time ago.
I’m thinking it may be the wrong gl.h for Borland 4.5. I just downloaded
BCC32 5.5 line compiler which includes a Borland gl.h. I’m going try
it later today when I get off work.

>the only thing that should be needed is to include windows.h before glut.h and then you >should be on your way (they say…).

…yep I have windows.h inlcuded before glut.h

#include <windows.h>
#include <GL/glut.h>
#include <stdio.h>
#include <stdlib.h>

>Do you think you could send me your windows.h (or wingdi.h if you have that one, it is >included from windows.h), the problem might be in there somewhere.

Sure, they’re both attached to this file.We may be on the right track here. I tried changing the compiler from one that accepts Borland Extensions to the ANSI standard. Now the errors are different, they’re in windows.h

The compiler only reports the first 26 errors I guess but I didn’t see anymore errors in gl.h (they might still be there, shifted to the bottom). The new errors are:

windows.h 209: , expected
windows.h 210: , expected
windows.h 213: , expected
windows.h 214: Multiple declartion for’_far’
windows.h 214: , expected
windows.h 216: Multiple declartion for’_near’
windows.h 216: , expected

Thanks again Mikael,


You definately want to check out this page:

From here, you can download the latest version of gl.h for Borland, as well as glut32.h, glut32.lib, and glut32.dll, also for Borland.

Also, make sure you include your ANSI headers before you include windoze.h. It does make a difference which order you put your include statements. Therefore, your code should look like:

/* ANSI C-Specific header files */

#include <stdio.h>
#include <stdlib.h>

/* Windoze specific header files */

#include <windoze.h>

/* OpenGL specific header files */

#include <gl/glut.h>

This’ll really help.

…uh, yeah…what about it?

I decided to upgrade. I’m using the Borland C++ 5.5 command line compiler now. I followed the directions at
and the compiler appears to be finding everything it needs. None of the previous
errors are showing. However there are two that I’m trying to figure out how to
deal with now. Here’s what’s happening when I compile at the command line…

bcc32 program1.cpp glut32.lib

Borland C++ 5.5.1 for Win32 Copyright (c) 1993, 2000 Borland
Error E2337 C:\Borland\BCC55\include\GL/glut.h 146: Only one of a set of overloaded functions can be “C”
Error E2015 program1.cpp 47: Ambiguity between ‘std::exit(int)’ and ‘exit(int)’
in function keyboard(unsigned char,int,int)
*** 2 errors in Compile ***

Error E2337: glut.h contains the line extern “C”, but it inlcudes gl.h&glu.h
which also declare functions as extern “C”. I’m not sure what
to do here.
Error E2015: I think the question here is whether to use exit() from Borland’s standard library or the user defined exit(). I see a prototype for exit() in glut.h, but I haven’t found where it is defined, so I don’t know which exit() function to use here[in program1.cpp].

I’m very thankful to everyone who has helped me so far.


I just downloaded the glut.h and got the same problem.

If you put your windows.h first and then your gl/glut.h the EXIT command is declared twice (your problem!)

I fixed this by commenting out line 146 (I think) in glut.h. It’s the one that reads something like:

extern _CRTIMP void __cdecl exit(int);

comment out this line and everything will be fine!


I commented out that line.

Both of these errors are now gone.

But a new one remains.

Error: ‘C:\BORLAND\BCC55\LIB\GLUT32.LIB’ contains invalid OMF record, type 0x21
(possibly COFF)

Did you get this one too?


If you include glut.h, you don’t need to include windows.h since it defines the required stuff by itself. You only need to include windows.h first if you’re only using gl.h and/or glu.h. The library error you got is probably because you’re using a lib-file in microsofts format which is not compatible with borland. Use the implib utility to get a correct version form opengl32.dll. And do a google search or check out the link above to find out how to do that.