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

2 answers

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?

    1 person found this answer helpful.
  2. Nancy Vo (WICLOUD CORPORATION) 7,250 Reputation points Microsoft External Staff Moderator
    2026-07-06T03:59:06.1233333+00:00

    Hello @Sid Kraft ,

    Thanks for your question.

    This usually happens because Visual Studio is very strict about exactly where and how it looks for files. Even if you give it the right folder, a small mismatched setting can make Visual Studio completely ignore it.

    You can refer to these following steps:

    1. Check your build dropdowns.

    Visual Studio has different profiles (like x86 for 32-bit, and x64 for 64-bit). If you added the folder to one profile, but are trying to run the other, it will not find the file.

    • Open your Project Properties.
    • At the very top of the window, change Configuration to All Configurations and Platform to All Platforms.
    • Add your C:\glutdlls36\ path again so it applies to everything.
    1. Use the Modern Settings Menu

    The VC++ Directories menu is an older way to link files. Visual Studio prefers a different menu for C++ files now.

    • In your Properties window, on the left side, expand C/C++ and click on General.
    • On the right side, find Additional Include Directories.
    • Click the dropdown, select <Edit...> and add C:\glutdlls36\ there instead.
    1. Check for a Subfolder

    Please open your C:\glutdlls36 folder on your computer using File Explorer and look inside.

    • If glut.h sitting right there in the open, #include <glut.h> is correct.
    • If glut.h inside another folder called GL, you should change your code to type #include <GL/glut.h>.

    I hope this addresses your question. If this response was helpful, please consider following the guidance to provide feedback.

    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.