Accessing OpenGL Libraries

Sid Kraft 46 Reputation points
2026-07-01T15:25:36.0066667+00:00

Using Visual Studio, C++ and want to include the OpenGL library elements. Have asked questions about doing and have had suggestions to use the Power Shell in Visual Studio and installing the OpenGL routines using the vcpkg install commands. Have received several errors and not successful yet, including manifest errors with vcpkg, etc. I do have the OpenGL library routines downloaded for C++ and in a file labeled: C:\glfw-3.4\Include\GLFW. In this directory are two include files for C++ called glfw3.h and glfw3native.h, could be used in my routine with includes:

#include <glfw3.h> and/or #include <glfw3native.h>, supposedly if included will provide the access to the OpenGL library routines for my program. Only one problem, how does one provide the access for the C++ program in Visual Studio, C++? Any advice will help, 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. Nancy Vo (WICLOUD CORPORATION) 6,595 Reputation points Microsoft External Staff Moderator
    2026-07-02T04:07:35.4066667+00:00

    Hello @Sid Kraft ,

    Thanks for your question.

    Tools like vcpkg automatically put files into the standard folders that Visual Studio always checks. Because you downloaded the files manually and placed them in C:\glfw-3.4\Include\GLFW, Visual Studio does not know they are there. It is only looking in its default locations.

    It requires two main phases: telling Visual Studio where your Header files (.h) are, and telling it where your Library files (.lib) are. You can refer to the following steps:

    Phase 1: Add the include directory

    1. Open project properties.
    • Open your project in Visual Studio.
    • Look at the Solution Explorer panel on the right side of your screen.
    • Right-click on your Project's name (the name of your specific project, not the Solution at the very top) and select Properties at the bottom of the menu.
    1. Add the include directory.
    • At the top of the Properties window, make sure Configuration is set to All Configurations and Platform is set to All Platforms.
    • On the left menu, expand C/C++ and click on General.
    • On the right side, find the line that says Additional Include Directories.
    • Click the dropdown arrow on the far right of that row, select <Edit...> and type in your exact path: C:\glfw-3.4\Include\GLFW.
    • Click OK, then Apply

    Phase 2: Add the library directory (for your .lib files)

    To actually run OpenGL, Visual Studio also needs the compiled library files that came with your download.

    1. Point to the folder.
    • Still in the Properties window, expand Linker on the left menu and click on General.
    • On the right side, find Additional Library Directories.
    • Click the dropdown, select <Edit...> and add the path to the folder containing your .lib files. (Note: In your GLFW download folder, this is usually a folder named something like lib-vc2022 or lib-mingw, depending on your version).
    • Click Apply.
    1. Specify the file.
    • Under the Linker menu on the left, click on Input.
    • On the right side, find Additional Dependencies.
    • Click the dropdown, select <Edit...> and type in the exact name of the library file: glfw3.lib
    • Press Enter to go to a new line, and also type: opengl32.lib.
    • Click OK.

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

    Was this answer helpful?

    0 comments No comments

  2. AI answer

    2026-07-01T15:26:16.7966667+00:00

    To make those GLFW/OpenGL headers usable in a Visual Studio C++ project, the project must know where to find:

    1. The header files (glfw3.h, glfw3native.h, and any other OpenGL headers like <GL/gl.h>)
    2. The corresponding libraries (.lib) at link time

    From the provided context, the relevant parts are how Visual Studio consumes libraries and how OpenGL headers are included.

    1. Include the OpenGL headers in code

    For core OpenGL and related Windows support, the headers are:

    • <GL/gl.h> for core OpenGL
    • <GL/glu.h> for the OpenGL Utility library
    • windows.h for WGL and Windows support functions

    Applications that use:

    1. The core OpenGL functions must include the header file <GL\gl.h>.
    2. The OpenGL Utility library must include the header file <GL\glu.h>.
    3. The WGL functions must include the header file windows.h.

    So a typical source file will start with something like:

    #include <windows.h>
    #include <GL/gl.h>
    #include <GL/glu.h>
    #include <GLFW/glfw3.h>   // once the include path is configured
    

    2. Tell Visual Studio where the GLFW headers are

    Since the GLFW headers are in C:\glfw-3.4\Include\GLFW, configure the project’s include directories so that #include <GLFW/glfw3.h> (or #include <glfw3.h> if you prefer) can be resolved.

    For a project that is not using vcpkg integration, the context describes the general pattern for consuming libraries that are not part of the solution:

    If the static library isn't part of the solution:

    1. Right-click on the application project node in Solution Explorer and then choose Properties.
    2. In the VC++ Directories property page, add the path to the directory that contains the LIB file to Library Directories. Then, add the path to the library header file(s) to Include Directories.
    3. In the Linker > Input property page, add the name of the LIB file to Additional Dependencies.

    Apply this pattern to GLFW:

    1. In Visual Studio, right-click the C++ project → Properties.
    2. Go to Configuration Properties → VC++ Directories.
    3. Add C:\glfw-3.4\Include to Include Directories.
      • With this, #include <GLFW/glfw3.h> will work (because the compiler will look into Include, then GLFW, then glfw3.h).

    3. Tell Visual Studio where the GLFW libraries are

    If GLFW was built and produced .lib files (for example in C:\glfw-3.4\lib), configure the linker:

    1. In the same Properties dialog, under VC++ Directories, add the folder that contains the GLFW .lib files (for example C:\glfw-3.4\lib) to Library Directories.
    2. Go to Configuration Properties → Linker → Input.
    3. Add the GLFW library name (for example glfw3.lib) to Additional Dependencies.

    This follows the documented pattern for consuming static libraries that are external to the solution.

    4. Using vcpkg (optional, when manifest issues are resolved)

    The context also describes vcpkg as the preferred way to install and consume third-party C/C++ libraries:

    The cross-platform vcpkg command-line tool greatly simplifies the discovery and installation of over 900 C++ open source libraries.

    To consume a library that you have downloaded by using the vcpkg package manager, you can ignore the instructions below.

    Once vcpkg is set up and a package is installed, Visual Studio integration (vcpkg integrate install) allows simply writing #include and having Visual Studio automatically add the library paths and copy DLLs as needed.

    However, since there are manifest errors with vcpkg in this scenario, the manual configuration steps above (include directories + library directories + linker input) are the way to provide access to the GLFW/OpenGL routines.


    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.