CppPilot

Linker diagnostic Visual Studio C++

LNK1181 cannot open input file

The linker was told to read an object file or a library that it cannot find.

Applies toMSVC on Windows; code and debugger concepts apply to MSBuild and CMake
ExamplesFocused excerpts; required context is stated alongside each example

Visual Studio property-page paths describe MSBuild projects. For CMake, configure the corresponding target or preset. Menu names can vary by Visual Studio version; use the cited reference for your toolset.

Build output
fatal error LNK1181: cannot open input file 'zlib.lib'

Causes & corrections

Find the case that matches your build. Each example shows what changes and why.

  1. The library name is wrong.

    Check the name in Linker > Input > Additional Dependencies against the file on disk, for example zlibd.lib in Debug.

    Problem

    Disk: lib\Debug\zlibd.libAdditional Dependencies: zlib.lib

    Correction

    Debug > Linker > Input > Additional Dependencieszlibd.lib;%(AdditionalDependencies)
    Note 1Use the actual filename produced by the library build.
  2. Its folder is not in the library directories.

    Add it to Linker > General > Additional Library Directories for every configuration and platform.

    Problem

    Disk: thirdparty\lib\zlib.libSearch paths omit thirdparty\lib

    Correction

    Linker > General > Additional Library Directories$(SolutionDir)thirdparty\lib;%(AdditionalLibraryDirectories)
    Note 2The dependency names the input; library directories tell the linker where to find it.
  3. The library is built by another project that has not run yet.

    Add a project reference to that project, so that Visual Studio builds it first and links it.

    Problem

    App links Core.lib before Core builds

    Correction

    App > Add > Reference > Projects > CoreCore builds first -> Core.lib -> App
    Note 3Prefer a project reference for a library built in the same solution.
  4. The name contains a space.

    An unquoted name with spaces in the additional options is read as two files: quote it.

    Problem

    // Linker Additional OptionsC:\Vendor SDK\lib\vendor.lib

    Correction

    // Linker Additional Options"C:\Vendor SDK\lib\vendor.lib"
    Note 4Quote a path containing spaces so the linker reads one input.

Sources and scope

Official references

These links document the compiler, build system, or debugger behavior discussed here. Use the version selector on Microsoft Learn for your toolset. Example blocks are focused excerpts; required headers and build settings are stated alongside them.

In your workspace

Investigate LNK1181 with CppPilot

CppPilot gives the selected AI the diagnostic, relevant code, and project settings for the active configuration. Choose Fix to request a correction, then check the result with a rebuild.

Use your own Codex or Claude account, or optional CppPilot Cloud access. Setup instructions

Visual Studio Marketplace