LINK : fatal error LNK1104: cannot open file — Identify the File First

LNK1104 means the MSVC linker could not open the filename shown in the error, either for reading or writing. Do not start with a generic linker fix. Read the filename first: an .exe/.pdb, Microsoft .lib, third-party .lib, project-built file, or suspicious path such as C:\Program.obj points to a different troubleshooting branch.

MSVC · LINK.exe · LNK1104Windows · Visual Studio / Build ToolsLast reviewed Sep 27, 2026
🎯 You’re likely in the right place if:
Your build reaches the link stage and reports fatal error LNK1104: cannot open file 'filename'.The missing or inaccessible filename is visible in the error.You are building with Microsoft LINK/MSVC from Visual Studio, MSBuild or a Developer Command Prompt.
Choose your path by the filename — not by LNK1104 alone
Your app.exe or app.pdb →The output may still be running, loaded in the debugger, or temporarily locked.kernel32.lib / MSVC or Windows library →Check inherited/default library paths and the selected toolset/SDK before repairing anything.A third-party .lib →Resolve the exact path LINK is trying to open, prove that file exists and is readable, then check library search paths/quoting. Architecture usually becomes the next linker issue after the file can be opened; it matters here mainly when configuration selects a different or nonexistent library path.A file built by another project →Check project references, build order and whether parallel builds can touch the same output.C:\Program.obj or another strange truncated path →Look for an unquoted path containing spaces or a malformed dependency entry.LNKnnn, temporary or unusual output file →Check TMP/TEMP, permissions, disk space, path length and large-file edge cases.
Difficulty: ModerateRisk: Low first
🔎 Quick Check — copy the filename from LNK1104

Start with the text inside the quotes. The extension and path tell you what the linker was trying to read or write.

LINK : fatal error LNK1104: cannot open file 'filename'

Verify: You can place the filename into one of the branches above. If you cannot, preserve the full linker command or build log before changing configuration.

Did the filename identify your branch?
ADSENSE · reserved slot after the first useful step

Why LNK1104 happens

Microsoft documents LNK1104 when the linker cannot open a file for reading or writing. Two common causes are a program/output file that is still in use and an incorrect or unquoted library path, but the same error code also covers missing Microsoft libraries, third-party libraries, project outputs and other file-access problems. That is why the filename is the diagnostic key.

Diagnostic flow — classify the file before fixing anything

1
Is it your .exe or .pdb?
Stop the running app and end the active debug session. Close tools that may have the output open, then rebuild.
2
Is it a Microsoft .lib such as kernel32.lib?
Treat this first as a toolset/Windows SDK/project configuration problem, not as a reason to download a library from the web.
3
Is it a third-party .lib?
Confirm the file exists at the expected location and matches the active build configuration and architecture.
4
Should another project create it?
Confirm that project builds first and that the consuming project references the correct output.
5
Does the path look truncated or impossible?
A filename such as C:\Program.obj strongly suggests a path containing spaces reached LINK without correct quoting.

Fix #2 — if LNK1104 names your .exe or .pdb, release the output file

If the filename is the executable being built or its program database, stop the application and unload it from the debugger. Also close any editor or tool that has the output open. If the lock is not obvious or recurs, identify the process holding the exact output path with an approved Windows handle/resource-monitoring tool before killing unrelated processes. If the owning process is unresponsive, end that specific process; restarting Visual Studio is a later fallback, not the first diagnostic step.

🟡 If security software is involved: Microsoft notes that antivirus scanning can temporarily lock newly created executable files. Do not disable endpoint protection globally. Confirm the lock first and follow your organization’s approved exclusion policy if a build-directory exclusion is actually required.

Verify: rebuild the same configuration and output path. Success means LINK can overwrite/create the same .exe or .pdb. If releasing one process fixes it only temporarily, capture which process reacquires the file rather than treating repeated IDE restarts as the solution.

Fix #3 — if it names a .lib, determine who owns that library

Microsoft library: first check that the active project still inherits the normal MSVC and Windows SDK library directories. In Visual Studio, inspect the active configuration/platform under VC++ Directories → Library Directories and Linker → General → Additional Library Directories. A custom value can accidentally replace inherited defaults instead of extending them. Then verify the intended C++ workload/toolset and Windows SDK are installed and selected. A standard library such as kernel32.lib, msvcprt.lib or msvcprtd.lib should not be “fixed” by downloading a replacement file.

Third-party library: resolve the exact .lib path that LINK is attempting to open, then confirm that specific file exists and the build identity can read it. In Visual Studio, inspect Configuration Properties → Linker → General → Additional Library Directories and Linker → Input → Additional Dependencies. For command-line builds, inspect /LIBPATH and the LIB environment. Debug/Release and x86/x64/ARM64 configuration matter because they often select different directories or filenames. An architecture mismatch in a file LINK successfully opens normally progresses to a different linker diagnostic; for LNK1104, focus first on why the selected file/path cannot be opened. In the Visual Studio Additional Dependencies property editor, keep each library as its own entry; do not paste a malformed combined filename.

Verify: resolve the final path for the exact library named by LNK1104, confirm it exists and is readable under the same build identity, then rerun the same LINK invocation/configuration. If LINK opens it and reports a machine-type, symbol, runtime or other linker error next, stop diagnosing LNK1104 and follow that new failure class.

Fix #4 — if another project should build the file, repair the dependency

When LNK1104 names a library or object produced by another project in the solution, first confirm that producer project successfully creates the expected file. Then check the project reference/dependency so it builds before the consumer. Do not mask a failed producer build by manually copying an old output into the consumer’s directory.

Parallel-build check: if multiple projects write, copy or consume the same file, temporarily build the producer first and the consumer second. If that works, repair the project dependency/output layout rather than permanently relying on serial builds. Microsoft notes that parallel builds can cause LNK1104 when one process locks a file another linker needs.

Verify: Clean/rebuild the relevant projects. The producer should create the expected file before the consumer reaches LINK, and the consumer should reference that current output.

Fix #5 — if the filename looks like C:\Program.obj, repair path quoting

Microsoft specifically documents C:\Program.obj as a symptom of an unquoted path beginning with C:\Program Files. Inspect /LIBPATH, LIB, VC++ Library Directories, Additional Library Directories and Additional Dependencies for paths containing spaces. Also inspect the exact Additional Dependencies entries: malformed separators can turn what should be separate library names into one impossible filename.

/LIBPATH:"C:\Program Files\Vendor SDK\lib"

Verify: Rebuild and inspect the error text. A correctly quoted path should no longer be split into a fake root-level object such as C:\Program.obj.

Fix #6 — if it is LNKnnn, temporary, unusually long or very large

Filename looks like LNKnnn: Microsoft identifies names of this form as temporary files created by the linker. Check that TMP/TEMP points to an existing writable directory and that the drive has free space.

Ordinary temporary/output file: verify the target directory exists and the current build identity can write there. Prefer fixing the specific inaccessible directory over running the whole IDE permanently as Administrator.

Very long path: if the resolved filename/path approaches the traditional Windows MAX_PATH boundary, shorten the project/output/library path and rebuild. Treat this as an edge case after the normal filename branches, not as a first fix.

Very large .lib or .obj: Microsoft also documents rare failures where the 32-bit linker can exhaust address space while handling very large files. If the named file is exceptionally large and ordinary path/access checks pass, use the 64-bit-hosted MSVC toolchain/linker rather than deleting or replacing the library.

Verify: For LNKnnn, confirm the build identity can create/remove a file in the resolved temp directory. For long paths, confirm the shortened resolved path is used. For very large inputs, confirm the build invokes the 64-bit-hosted linker and moves past the same file.

What not to do

Do not download missing Microsoft .lib/.dll files from unofficial sites.Do not add random library directories until you know which file LNK1104 names.Do not globally disable antivirus or endpoint protection just to test a suspected file lock.Do not copy stale project outputs around to hide an incorrect dependency/build order.Do not assume x86 and x64 libraries are interchangeable.Do not overwrite inherited MSVC/Windows SDK library directories with a custom path unless you intentionally reproduce the defaults.Do not treat a successful serial build as the final fix for a parallel-build race; repair the dependency or shared-output design.Do not treat x86/x64 mismatch as the direct explanation for LNK1104 when LINK can open the file; architecture incompatibility normally becomes a different linker diagnostic.Do not assume “the file exists” proves LINK can open the exact resolved path under the build identity.Do not keep diagnosing the original LNK1104 once LINK progresses and emits a different machine-type, symbol, runtime or access diagnostic.

Still seeing LNK1104?

Capture the exact filename, its resolved full path and the active build context before changing anything else. Preserve the final LINK command when possible: two builds with the same visible LNK1104 text can be searching different directories because of configuration, environment or generated-command differences. If the filename or resolved path changes after a fix, treat it as a new diagnostic branch rather than assuming the original cause remains.

Before escalating, capture:the complete LNK1104 line including the filenameVisual Studio/MSVC toolset and Windows SDK versionDebug/Release and x86/x64/ARM64 configurationthe final LINK command or verbose build logwhether the named file exists, its resolved full path, and whether the exact build identity can read/write it as requiredwhether the file is an output, Microsoft library, third-party library or project-generated dependency

Official references

Still stuck? Ask the community

Share the exact filename from LNK1104, your active configuration, toolset/SDK version and which branch you already checked.

Keep it safe: never post passwords, API keys, access tokens, recovery codes, license keys, private URLs, or confidential logs.
Powered by GitHub DiscussionsSign in with GitHub to comment. Reading comments does not require sign-in.

Loading community discussion…