Freeglut Download

Sid Kraft 96 Reputation points
2026-07-28T18:22:50.1466667+00:00

Using C++ with visual Studio, been trying extensively to execute the OpenGL commands and the glutInit functions to open a window to output graphics. Have all of the instructions that I need to execute but having trouble accessing the header files glut.h and gl.h where the functions reside. After looking at the items in c:\freeglut-3.8.0\include\GL, they are all header files, no .lib or .obj files! No wonder I cannot open the headers. In the project added directories, inputting to the VC++ and C++ locations "c:\freeglut-3.8.0\include\GL and in the linker glut.h;gl.h. Seems simple enough but cannot execute, keep getting a link error cannot find glut.h I have tried many combinations but does not work. Getting so frustrated as this should not be that hard? I also loaded the Microsoft vcpkg program and executed install OpenGL, this seemed to work but totally confused why I am having so much trouble, Sid Kraft

Developer technologies | Visual Studio | Other
Developer technologies | Visual Studio | Other

A family of Microsoft suites of integrated development tools for building applications for Windows, the web, mobile devices and many other platforms. Miscellaneous topics that do not fit into specific categories.

0 comments No comments

1 answer

Sort by: Most helpful
  1. AI answer

    2026-07-28T18:23:14.4933333+00:00

    gl.h and glut.h are header files, so they do not belong in the linker input. The linker needs .lib files, while headers must be found through the compiler include search path.

    For OpenGL on Windows:

    1. Include the correct headers in code:
      • Core OpenGL: #include <GL\gl.h>
      • GLU: #include <GL\glu.h>
      • WGL/Windows support: #include <Windows.h>
    2. Fix the include path in Visual Studio:
      • Open Project Properties.
      • Go to Configuration Properties > VC++ Directories > Include Directories.
      • Add the parent include folder, not the GL folder itself if the code uses #include <GL\...>.
      • Example: if headers are under c:\freeglut-3.8.0\include\GL, add c:\freeglut-3.8.0\include.
    3. Use the include directive that matches the search path:
      • If the include directory is c:\freeglut-3.8.0\include, use #include <GL\gl.h> and #include <GL\glut.h>.
      • Do not add part of the path twice. If ...\include is already in Include Directories, #include <GL\glut.h> is correct; #include <include\GL\glut.h> would fail.
    4. Fix the linker settings:
      • Remove glut.h and gl.h from linker input.
      • In Configuration Properties > Linker > General > Additional Library Directories, add the folder that contains the .lib files.
      • In Configuration Properties > Linker > Input, add the actual library filenames, not headers.
    5. If building from the Developer Command Prompt, verify environment paths:
      • Check INCLUDE, LIB, and LIBPATH.
      • If a library or SDK was installed recently, open a new Developer Command Prompt so updated environment variables are picked up.
    6. If using vcpkg, it can automate installation and setup for many third-party libraries. That is often easier than manually wiring include and library paths.

    The current error is caused by treating header files as linker inputs. The compiler finds headers through Include Directories or /I; the linker finds .lib files through Library Directories or /LIBPATH.


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

    Was this answer helpful?

    2 people found 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.