Microsoft KB Archive/815645

= You receive a &quot;fatal error LNK1181&quot; error message when you build a Managed C++ application =

Article ID: 815645

Article Last Modified on 11/14/2007

-

APPLIES TO


 * Microsoft Visual C++ .NET 2003 Standard Edition
 * Microsoft Visual C++ .NET 2002 Standard Edition
 * Microsoft Linker (LINK.EXE)
 * Microsoft Visual C++ 2005 Express Edition

-





SYMPTOMS
This article describes linker error LNK1181. When you build a Managed C++ application, you may receive the following error message:

fatal error LNK1181: cannot open input file filename



CAUSE
This error occurs because the linker cannot find the file name or the file path that is specified in the project properties. However, the file path that is mentioned in the project properties is correct because the linker does not handle the space character in the file path.



RESOLUTION
To resolve this error, use the path without space characters, or use quotation marks around the path in project properties.



STATUS
This behavior is by design.



MORE INFORMATION
LNK1181 occurs when the .lib or .obj files that are specified during linking, are not found in the current directory, any of the directories that are specified by the LIBPATH linker option, or any of the directories that are specified in the LIB environment variable.

The error may occur in the following scenarios:  ==== Scenario 1: ====

If the library that generates the error was added to the project with a fully qualified path, the path may be invalid. The path is invalid if it is not present on the system or if the path contains space characters.  Start Microsoft Visual Studio .NET or Microsoft Visual Studio 2005. On the File menu, point to New, and then click Project. In Visual C++ .NET 2002, click Visual C++ Projects under Project Types, and then click Managed C++ Application under Templates.

In Visual C++ .NET 2003, click Visual C++ Projects under Project Types, and then click Console Application (.NET) under Templates.

In Visual C++2005, click Visual C++ under Project Types, and then click CLR Console Application under Templates. In the Name text box, type TestLib .</li> In the Location text box, type C:\Test, and then click OK.</li> In Solution Explorer, right-click the project, and then click Properties.</li> In the Property Pages dialog box, expand Linker, and then click Input.</li> In the Additional Dependencies field, type the library file. For example, you can type C:\Program Files\mylib\mylib.lib.

You may receive the following error message when you build the project:

fatal error LNK1181: cannot open input file 'C:\Program.obj'

</li></ol> </li> ==== Scenario 2: ====

The linker error LNK1181 may also occur if you add an unqualified file to the Additional Dependencies project property, and that file does not exist in any of the search directories that are defined in the LIB environment variable or the /LIBPATH project property.

You may add the directory that contains library file to the LIBPATH to resolve the problem: <ol> In Solution Explorer, right-click the project, and then click Properties.</li> In the Property Pages dialog box, expand Linker, and then click General.</li> In the Additional Library Directories field, specify the required library path.</li></ol> </li></ul>

<div class="references_section">