OpenGL using vcpkg

Sid Kraft 46 Reputation points
2026-07-08T23:19:31.49+00:00

The solution did work for downloading and executing the vcpkg program by bypassing the strict, built in version . However, after the statement #include <GL/gl.h> and did the re-load in visual studio with C++, the loader still gave me the error "could not open the .obj file as specified". I suspect it is because of the additional Configuration Properties-->C/C++ --> General --> Additional Include Directories not pointing to the correct files for the #include and the Configuration Properties -->Linker-->General-->Additional Library Directories also not pointing to the proper locations. From your experience where should these additional directories be pointing? 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.


3 answers

Sort by: Most helpful
  1. Taki Ly (WICLOUD CORPORATION) 2,815 Reputation points Microsoft External Staff Moderator
    2026-07-09T03:02:26.7533333+00:00

    Hello @Sid Kraft ,

    When working with vcpkg and Visual Studio, it might be beneficial to consider using its built-in MSBuild integration rather than configuring the directory paths manually. Running the command vcpkg integrate install in your command prompt typically allows Visual Studio to automatically locate the necessary include headers and libraries for all installed packages. You may want to review the vcpkg MSBuild integration documentation for more details on how this background linking operates. If you decide to try this, it is generally recommended to clear out the manual paths you previously added to avoid potential conflicts.

    However, if manual configuration is preferred or required for your specific project setup, the directories typically point to the installed folder within your vcpkg root directory. Depending on your target architecture (e.g., x64-windows or x86-windows), the paths might generally look like this:

    • Include Directories: [vcpkg_root]\installed\[target-triplet]\include
    • Library Directories: [vcpkg_root]\installed\[target-triplet]\lib

    Regarding the "could not open the .obj file as specified" linker error, this specific message sometimes indicates that a .obj file name was inadvertently entered into the Configuration Properties -> Linker -> Input -> Additional Dependencies field. External libraries are usually provided as .lib files rather than .obj.

    I hope this information points you in the right direction! If you found my response helpful or informative, I would greatly appreciate it if you could follow this guide for your confirmation.

    Thank you.

    Was this answer helpful?


  2. kagiyama yutaka 4,175 Reputation points
    2026-07-08T23:34:49.1166667+00:00

    I think the dirs u need are the ones vcpkg actually writes <vcpkg_root>\installed<triplet>\include and <vcpkg_root>\installed<triplet>\lib set those in VS.

    Was this answer helpful?

    0 comments No comments

  3. AI answer

    2026-07-08T23:20:10.8266667+00:00

    For headers and libraries installed by vcpkg, the include and library paths should point into the vcpkg installation tree, not to arbitrary system folders.

    In general:

    1. Header search path (#include <GL/gl.h>)
      In Visual Studio, set:
      • Configuration Properties → C/C++ → General → Additional Include Directories
      • This should include the vcpkg include directory for the triplet you are using, for example:
        • …\vcpkg\installed\x64-windows\include The compiler then finds GL/gl.h via the normal include search order:
      • Local directory
      • Directories specified by /I (Additional Include Directories)
      • Directories from the INCLUDE environment variable
      Alternatively, use vcpkg integrate install so Visual Studio automatically adds the correct include directories. If user‑wide integration is enabled, make sure Additional Include Directories is set to inherit from parent; leaving it blank without inheritance overrides vcpkg’s augmented defaults and headers won’t be found.
    2. Library search path (linking OpenGL)
      In Visual Studio, set:
      • Configuration Properties → Linker → General → Additional Library Directories
      • This should include the vcpkg lib directory for the same triplet, for example:
        • …\vcpkg\installed\x64-windows\lib
      If the linker still reports it “can’t open” a .lib or .obj file:
      • Verify the path is correct and, if it contains spaces, that it is wrapped in double quotes.
      • Ensure you are building for the same architecture as the installed libraries (for example, x64 project with x64 vcpkg triplet).
      • If needed, override or add a library directory with the Additional Library Directories property or /LIBPATH on the command line.
    3. Using vcpkg integration
      When vcpkg is integrated with Visual Studio (vcpkg integrate install), Visual Studio can automatically:
      • Add the vcpkg include and library paths to new C++ projects.
      • Copy required DLLs to the solution folder. In that case, avoid manually overriding include/library directories unless necessary; let the project properties inherit the vcpkg defaults.

    If the error mentions a specific .obj or .lib file name, confirm that file actually exists under …\vcpkg\installed\<triplet>\lib and that the corresponding include directory is under …\vcpkg\installed\<triplet>\include.


    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.