Opengl Includes

Sid Kraft 46 Reputation points
2026-07-03T13:43:10.9766667+00:00

Have a file called C:\glutdlls36 and in this file are the libraries and header directives for the C++ program, i.e. glut.h. I am trying to include the OpenGL routines in C++ using Visual Studio. I execute the following commands, in Visual Studio from one of my projects as:

-Project

-xxxx Properties(xxxx my project name)

-VC++Directories

-Include Directories

-C:\glutdlls36\

Save and include the library routine

#include <glut.h> which is in the file referenced, i.e. C:\glutdlls36

The system says that it cannot open the include header as provided. Not sure why the header cannot be opened but any help will be appreciated, Sid Kraft

Developer technologies | C++
Developer technologies | C++

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.

0 comments No comments

1 answer

Sort by: Most helpful
  1. AI answer

    2026-07-03T13:43:23.1366667+00:00

    #include <glut.h> uses the angle‑bracket form, so the compiler does not look in the parent source file’s directory. It searches only the include paths specified on the command line (/I) and then the INCLUDE environment variable.

    In Visual Studio, the equivalent of /I is the project’s Additional Include Directories setting, not the general VC++ Directories page. To make #include <glut.h> work:

    1. Open the project properties for the specific project.
    2. Go to Configuration Properties → C/C++ → General → Additional Include Directories.
    3. Add C:\glutdlls36 to this list.
    4. Apply and rebuild.

    Alternatively, use the quoted form and rely on the parent/source directory search order:

    #include "glut.h"
    

    In that case, either place glut.h in the same directory as the source file or ensure the directory is in the include search path as above.

    Key points from the include search rules:

    • Quoted form #include "file" searches:
      1. Directory of the file that contains the #include.
      2. Directories of currently opened include files (parent, grandparent), in reverse order.
      3. Directories specified by /I.
      4. Directories in the INCLUDE environment variable.
    • Angle‑bracket form #include <file> searches:
      1. Directories specified by /I.
      2. Directories in the INCLUDE environment variable (for command‑line builds).

    If C:\glutdlls36 is only set in VC++ Directories and not in Additional Include Directories, the compiler’s C/C++ include search will not find glut.h, which explains the error.

    Also ensure the header name matches what OpenGL expects. Core OpenGL headers are typically included as:

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

    If glut.h is in a subfolder (for example C:\glutdlls36\GL\glut.h), add C:\glutdlls36 to Additional Include Directories and include it as:

    #include <GL/glut.h>
    

    References:

    AI-generated content may be incorrect. Read our transparency notes for more information.

    Was this answer helpful?

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.