visual studio 2026

Mitta mohith 0 Reputation points
2026-09-02T10:15:04.7833333+00:00

cannot open file 'msvcprtd.lib'

I have already included the GLFW, GLAD, Shader, and stb_image files correctly. The error appears during the linking stage, not while compiling the C++ code. I want to know why Visual Studio is looking for

msvcportlib.lib

and how I can fix the project/library configuration.

I am using Visual Studio for an OpenGL 4.6 project.

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. Tony Thach (WICLOUD CORPORATION) 745 Reputation points Microsoft External Staff Moderator
    2026-09-02T10:33:14.02+00:00

    Hi @Mitta mohith , and thanks for posting your question.

    Please first copy the complete LNK1104 line from View > Output > Build, because the two library names have different meanings:

    • msvcprtd.lib is a valid Microsoft debug C++ runtime library.
    • msvcportlib.lib is not a standard MSVC library name and is likely an incorrect dependency.

    If the actual error is:

    LNK1104: cannot open file 'msvcprtd.lib'
    

    the most likely cause is that the project has replaced Visual Studio’s default library paths while adding the GLFW library directory.

    Open Project > Properties, select the failing configuration such as Debug | x64, then check:

    VC++ Directories > Library Directories

    Open the drop-down and select Inherit from parent or project defaults. Add the GLFW path under Linker > General > Additional Library Directories instead of replacing the default MSVC library directories.

    Also confirm that Desktop development with C++, the MSVC toolset, and a Windows SDK are installed in Visual Studio Installer. MSVCPRTD.lib should be supplied and located automatically by the MSVC toolset.

    If the error actually says:

    LNK1104: cannot open file 'msvcportlib.lib'
    

    check Linker > Input > Additional Dependencies and remove that entry. Also search the project for:

    #pragma comment(lib, "msvcportlib.lib")
    

    If the name is not present in the project settings or source code, it may be embedded in a prebuilt library. Check it from a Developer Command Prompt:

    dumpbin /directives path\to\glfw3.lib | findstr /i msvcport
    

    If GLFW or another .lib contains /DEFAULTLIB:msvcportlib.lib, rebuild that library with the same Visual Studio toolset and platform as the application.

    If the source is still unclear, enable Tools > Options > Projects and Solutions > Build and Run > MSBuild project build output verbosity > Diagnostic, rebuild, and search the Output window for the library name.

    Do not download a random copy of the missing .lib. Restore the inherited MSVC paths or remove/rebuild the dependency that requests the incorrect library.

    If this instruction is applicable to your situation, I would greatly appreciate it if you could follow the instruction here so others experiencing similar behavior can benefit from it as well.  

    Was this answer helpful?

    1 person found this answer helpful.
    0 comments No comments

  2. AI answer

    2026-09-02T10:15:26.2466667+00:00

    msvcprtd.lib is the Microsoft C++ Standard Library debug import library. It is selected when the project uses the Debug DLL runtime setting, which corresponds to /MDd.

    Visual Studio looks for it because the project or one of the linked objects was built with a runtime-library setting that requires the debug C++ standard library. The CRT/STL library mapping is:

    • msvcprt.lib/MD
    • msvcprtd.lib/MDd
    • libcpmt.lib/MT
    • libcpmtd.lib/MTd

    msvcportlib.lib is not the standard Microsoft library name shown in the documentation. If the actual linker error is msvcprtd.lib, focus on runtime-library and toolset configuration.

    To fix the project configuration:

    1. Check the Runtime Library setting
      In the project properties, make sure the runtime setting matches the build configuration being used.
      • Debug commonly uses /MDd
      • Release commonly uses /MD
    2. Make sure the required MSVC libraries are installed
      If a standard Microsoft library such as msvcprtd.lib cannot be opened, verify that the required Visual Studio C++ components and Windows SDK are installed. If needed, modify the Visual Studio installation and add the missing C++ libraries/toolsets.
    3. Verify Platform Toolset and Windows SDK Version
      In the project’s General property page, confirm that the selected Platform Toolset and Windows SDK Version are installed.
    4. Check library search paths
      If library directories are incorrect or stale, the linker may fail to find standard libraries.
      • Verify VC++ Directories > Library Directories
      • Verify Linker > General > Additional Library Directories
      • For command-line builds, verify the LIB environment variable
    5. Make sure all libraries use compatible settings
      If GLFW, GLAD, or any other library was built with different compiler/runtime settings, linker problems can occur. Avoid mixing libraries built with different compiler versions or different runtime-library settings. Build all components with the same compiler toolset and compatible runtime settings.
    6. Check architecture match
      Ensure the project and all linked libraries are built for the same architecture, such as x64 with x64.
    7. Clean and rebuild
      An out-of-date object or library can also cause linker mismatches. Perform a clean build before further changes.

    If the project is intended to use the debug DLL runtime, the usual root causes are:

    • missing MSVC C++ toolset components,
    • incorrect library directories,
    • mismatched toolset/runtime settings across project and libraries.

    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.