Search code examples
c++openglgraphicsgame-engineglfw

GLFW cannot compile without "glu.h" and "windows.h"


I want to create a game engine, but my graphics subsystem will not compile without <GL/glu.h> and <windows.h>.

  1. Compiling Graphics.cpp with only <GLFW/glfw3.h>, without both headers will print the error on Graphics.cpp, 'gluErrorString' was not declared in this scope.
  2. Compiling Graphics.cpp with <GLFW/glfw3.h> AND '', without <windows.h> will print the error on glu.h, c:\mingw\include\gl\glu.h|225|error: 'WINGDIAPI' does not name a type. Some workaround I found is to include also the <windows.h> in Graphics.cpp.
  3. Compiling Graphics.cpp with <GLFW/glfw3.h> AND '' AND <windows.h> returns no error. The problem is that this program is not cross-platform isn't it?

As stated in GLFW build guide in the Including the GLFW header file section; One does not need to include windows.h and OpenGL header files, since GLFW header already included these. So I am trying to follow the guide or best practice, and trying to make my game engine cross-platform.

Followings are my linker options in CodeBlock,

-lglfw3
-lOpenGL32
-lglu32
-lgdi32

Solution

  • Turns out I only have to write GLFW_INCLUDE_GLU in CodeBlock's compiler settings in the #defines section.

    Source: Building GLFW program, by Sugih Jamin