Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Page 2 of 2 FirstFirst 12
Results 11 to 14 of 14

Thread: error C1189: #error : gl.h included before glew.h

  1. #11
    Member Regular Contributor
    Join Date
    Jul 2012
    Posts
    420
    Well, I could navigate threw the file, but it is not possible (at least to me) to open/view any files, nor to download them...
    Maybe someone else will have more luck...

  2. #12
    Junior Member Newbie
    Join Date
    Apr 2017
    Posts
    6
    Quote Originally Posted by Silence View Post
    Well, I could navigate threw the file, but it is not possible (at least to me) to open/view any files, nor to download them...
    Maybe someone else will have more luck...
    Kindly try this link: http://www.mediafire.com/file/vbfz3q.../Pacman_AI.rar.

  3. #13
    Member Regular Contributor
    Join Date
    Jul 2012
    Posts
    420
    Had not tried this since I don't have visual studio here, but in GameObject.h you include glut.h (which includes gl.h). If, for some reasons, this file is included before the other ones, then you'll have gl.h included before glew.h

  4. #14
    Senior Member OpenGL Guru Dark Photon's Avatar
    Join Date
    Oct 2004
    Location
    Druidia
    Posts
    4,124
    Silence is right.

    I pulled it this morning, hacked the ToolsVersion and PlatformToolset so it'd build, and tried a rebuild. Your Initializer.cpp fails to build with:
    Code :
    1>c:\...\pacman_ai\pacman_ai\pacman_ai\include\gl\glew.h(85): fatal error C1189: #error :  gl.h included before glew.h

    Initializer.cpp includes Initializer.h, which includes: Pacman.h, Maze.h, Food.h, Monster.h, and Mesh.h.

    Pacman.h -> GameObject.h -> GL/glut.h
    Mesh.h -> GL/glew.h

    So it's the inclusion of GL/glut.h before GL/glew.h which is pulling in GL/gl.h before GL/glew.h and causing your problem. If you include <GL/glew.h> at the top of Initializer.h, that avoids your problem.

    As a better solution, I'd recommend you create a "gl_includes.h" which includes <GL/glew.h> and <GL/glut.h> (in that order), and then you change your .h and .cpp files so that they only pull in "gl_includes.h". This will ensure you always get these headers in the right order.
    Last edited by Dark Photon; 04-20-2017 at 05:29 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •