none
Plz help, having problems creating a library that includes gl.h

    Question

  •  

    I'm trying to create a library that includes opengl, I've tryed to simplify things as much as possible so I created only one class, the code looks like this:

     

    Code Block

     

    #pragma once

     

    #ifdef WIN32

    #include <gl/gl.h>

    #endif

    class Class1

    {

    public:

    Class1(void);

    ~Class1(void);

    };

     

     

    but it seems that it doesn't like including gl.h, when I build it gives me 143 errors, this is how the errors look like:

     

    Code Block

    c:\program files\microsoft visual studio 8\vc\include\gl\gl.h(1152) : error C2144: syntax error : 'void' should be preceded by ';'

    c:\program files\microsoft visual studio 8\vc\include\gl\gl.h(1152) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int

    c:\program files\microsoft visual studio 8\vc\include\gl\gl.h(1152) : error C2146: syntax error : missing ';' before identifier 'glAccum'

    c:\program files\microsoft visual studio 8\vc\include\gl\gl.h(1152) : error C2182: 'APIENTRY' : illegal use of type 'void'

    c:\program files\microsoft visual studio 8\vc\include\gl\gl.h(1152) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int

    c:\program files\microsoft visual studio 8\vc\include\gl\gl.h(1153) : error C2144: syntax error : 'void' should be preceded by ';'

    c:\program files\microsoft visual studio 8\vc\include\gl\gl.h(1153) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int

    c:\program files\microsoft visual studio 8\vc\include\gl\gl.h(1153) : error C2086: 'int WINGDIAPI' : redefinition

    c:\program files\microsoft visual studio 8\vc\include\gl\gl.h(1152) : see declaration of 'WINGDIAPI'

    c:\program files\microsoft visual studio 8\vc\include\gl\gl.h(1153) : error C2146: syntax error : missing ';' before identifier 'glAlphaFunc'

    c:\program files\microsoft visual studio 8\vc\include\gl\gl.h(1153) : error C2182: 'APIENTRY' : illegal use of type 'void'

     

     

     

    I'm using the Win32 Console Application with the no precompiled headers option to create the library.

     

    I've  created a simple vector math library using the win32 console application before (but without including opengl) and it works just fine.

     

    Any idea where am I going wrong??

    P.S. later I'll need to include glu.h as well.

    Many thanks in advance.

    Hasan.

    Tuesday, October 09, 2007 9:34 AM

Answers

  • Since the first error is caused by undefined POINT, which is defined in WinDef.h file used usually via Windows.h, I would suggest one more #include:

     

    #include <Windows.h>

    #include <WinGDI.h>

    #include <gl/gl.h>

    . . .

     

    For certain reason, probably it would be enough this:

     

    #include <Windows.h>

    #include <gl/gl.h>

    . . .

     

    I hope this helps.

    Tuesday, October 09, 2007 11:49 AM

All replies

  •  

    You have to show us the code in gl.h around the line that is mentioned in the error message.

    The compiler error indicates there is a problem at line 1152, so if we could see what was there we might be able to tell you what is wrong.

    Tuesday, October 09, 2007 10:58 AM
  • Since the first error is caused by undefined WINGDIAPI, which is defined in WinGDI.h file, I would suggest one more #include:

     

    #include <WinGDI.h>

    #include <gl/gl.h>

    . . .

     

    I hope this helps.

     

    Tuesday, October 09, 2007 11:13 AM
  •  

    Thanks Bruno,

     

    Sorry I didn't post the code from gl.h because I didn't expect it to be the problem as I've used gl.h in win32 console applicatinos before (but not as a library) and it worked fine, anyway, here is the code. The compiler is complaining about lines 1152 to 1172 but just keeps repeating the same errors for each line. Here is the code which it's complaining about from gl.h

     

    Code Block

    WINGDIAPI void APIENTRY glAccum (GLenum op, GLfloat value);

    WINGDIAPI void APIENTRY glAlphaFunc (GLenum func, GLclampf ref);

    WINGDIAPI GLboolean APIENTRY glAreTexturesResident (GLsizei n, const GLuint *textures, GLboolean *residences);

    WINGDIAPI void APIENTRY glArrayElement (GLint i);

    WINGDIAPI void APIENTRY glBegin (GLenum mode);

    WINGDIAPI void APIENTRY glBindTexture (GLenum target, GLuint texture);

    WINGDIAPI void APIENTRY glBitmap (GLsizei width, GLsizei height, GLfloat xorig, GLfloat yorig, GLfloat xmove, GLfloat ymove, const GLubyte *bitmap);

    WINGDIAPI void APIENTRY glBlendFunc (GLenum sfactor, GLenum dfactor);

    WINGDIAPI void APIENTRY glCallList (GLuint list);

    WINGDIAPI void APIENTRY glCallLists (GLsizei n, GLenum type, const GLvoid *lists);

    WINGDIAPI void APIENTRY glClear (GLbitfield mask);

    WINGDIAPI void APIENTRY glClearAccum (GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha);

    WINGDIAPI void APIENTRY glClearColor (GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha);

    WINGDIAPI void APIENTRY glClearDepth (GLclampd depth);

    WINGDIAPI void APIENTRY glClearIndex (GLfloat c);

    WINGDIAPI void APIENTRY glClearStencil (GLint s);

    WINGDIAPI void APIENTRY glClipPlane (GLenum plane, const GLdouble *equation);

    WINGDIAPI void APIENTRY glColor3b (GLbyte red, GLbyte green, GLbyte blue);

    WINGDIAPI void APIENTRY glColor3bv (const GLbyte *v);

    WINGDIAPI void APIENTRY glColor3d (GLdouble red, GLdouble green, GLdouble blue);

    WINGDIAPI void APIENTRY glColor3dv (const GLdouble *v);

     

     

     

    Cheers,

    Hasan.

    Tuesday, October 09, 2007 11:23 AM
  •  

    Thanks Viorel,

    I just tried what you told me, no compliation errors in gl.h but 243 errors in WinGDI.h

     

    here is part of the errors:

    Code Block

     

    c:\program files\microsoft visual studio 8\vc\platformsdk\include\wingdi.h(268) : error C2146: syntax error : missing ';' before identifier 'ptPosition'

    c:\program files\microsoft visual studio 8\vc\platformsdk\include\wingdi.h(268) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int

    c:\program files\microsoft visual studio 8\vc\platformsdk\include\wingdi.h(268) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int

    c:\program files\microsoft visual studio 8\vc\platformsdk\include\wingdi.h(269) : error C2146: syntax error : missing ';' before identifier 'ptSize'

    c:\program files\microsoft visual studio 8\vc\platformsdk\include\wingdi.h(269) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int

    c:\program files\microsoft visual studio 8\vc\platformsdk\include\wingdi.h(269) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int

    c:\program files\microsoft visual studio 8\vc\platformsdk\include\wingdi.h(270) : error C2146: syntax error : missing ';' before identifier 'wStyle'

    c:\program files\microsoft visual studio 8\vc\platformsdk\include\wingdi.h(270) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int

    c:\program files\microsoft visual studio 8\vc\platformsdk\include\wingdi.h(270) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int

    c:\program files\microsoft visual studio 8\vc\platformsdk\include\wingdi.h(271) : error C2146: syntax error : missing ';' before identifier 'wPattern'

    c:\program files\microsoft visual studio 8\vc\platformsdk\include\wingdi.h(271) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int

    c:\program files\microsoft visual studio 8\vc\platformsdk\include\wingdi.h(271) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int

     

     

    And here is lines 268 to 271 of the WinGDI.h

    Code Block

    POINT ptPosition;

    POINT ptSize;

    WORD wStyle;

    WORD wPattern;

     

    Does it seem like now I need to include another file that would define POINT and WORD??
    Tuesday, October 09, 2007 11:38 AM
  • Since the first error is caused by undefined POINT, which is defined in WinDef.h file used usually via Windows.h, I would suggest one more #include:

     

    #include <Windows.h>

    #include <WinGDI.h>

    #include <gl/gl.h>

    . . .

     

    For certain reason, probably it would be enough this:

     

    #include <Windows.h>

    #include <gl/gl.h>

    . . .

     

    I hope this helps.

    Tuesday, October 09, 2007 11:49 AM
  •  

    Thanks Viorel, that just worked Big SmileBig Smile.. awesome!!

    Tuesday, October 09, 2007 12:48 PM