MSVC build errors > LNK1104
LNK1104: cannot open file
fatal error LNK1104: cannot open file 'mylib.lib'
The linker could not open a file it needs: a library it was told to link, or the executable it writes.
Causes and fixes
- The library folder is not in the search path. Add it to Linker > General > Additional Library Directories for the configuration and platform you build. Paths set only for Debug or only for Win32 are a common trap.
- The library is built by another project that has not been built yet. Add a project reference, or a build dependency in Project Dependencies, so that the library is built first.
- The file name contains the wrong configuration or platform. Check macros such as
$(Configuration)and$(Platform)in the dependency name and in the library directories. - The file is the program itself, and it is still running. When the message names your
.exeor.dll, close the running program or stop debugging; an antivirus scanning the file can also lock it briefly.
Fix LNK1104 with CppPilot
CppPilot reads the error, your code, and the project settings Visual Studio evaluates for the active configuration, then explains which of these causes applies. Choose Fix and the AI corrects it; CppPilot rebuilds the project and checks that the error is gone. Every change appears in Visual Studio for your approval.
Let the AI fix it in Visual Studio
CppPilot is a free extension that explains and fixes MSVC build errors with Codex, Claude, or CppPilot Cloud.
Related errors: LNK1168, LNK2019, C1083. See all guides.