A high-level, general-purpose programming language, created as an extension of the C programming language, that has object-oriented, generic, and functional features in addition to facilities for low-level memory manipulation.
For OpenGL on Windows, these headers are the relevant ones:
- Core OpenGL:
#include <GL\gl.h> - OpenGL Utility Library:
#include <GL\glu.h> - WGL and Windows support:
#include <windows.h>
If a header such as GL\glut.h or another OpenGL-related header cannot be found, that means the compiler include search path does not contain the directory where that header exists.
In Visual Studio, add include paths here:
- Open Project Properties.
- Go to Configuration Properties > C/C++ > General.
- Edit Additional Include Directories.
- If adding more than one directory in that property, separate them with a semicolon (
;).
Visual Studio also has VC++ Directories > Include Directories, but for the compiler option itself, C/C++ > General > Additional Include Directories is the documented place to add include directories.
How include lookup works:
-
#include "file.h"searches the source file’s directory first, then parent include directories, then directories from/I, thenINCLUDE. -
#include <file.h>searches the directories specified by/Ifirst, thenINCLUDE. - If using a relative path in the include directive, use double quotes, not angle brackets.
If building inside the Visual Studio IDE, the INCLUDE environment variable is ignored, and the project include directory settings are used instead.
For command-line builds, /I adds include directories. Example behavior:
-
/I path1 /I path2 - directories are searched in the order specified
If the header is physically under a folder structure like ...\GL\glut.h, then the include directory should be the parent folder above GL, and the source should use:
#include <GL\glut.h>
If the include directory already points directly to the GL folder, then the directive would need to match that layout. The include path and the #include text must be consistent.
Also check that the file is actually present where expected. A file being part of a project or downloaded separately does not make it automatically discoverable by the compiler unless it is in the include search path.