Microsoft KB Archive/814421

= BUG: You receive &quot;LNK1118&quot; and &quot;LNK1141&quot; errors when the project name contains a space character =

Article ID: 814421

Article Last Modified on 5/11/2007

-

APPLIES TO


 * Microsoft Visual C++ .NET 2003 Standard Edition
 * Microsoft Visual C++ .NET 2002 Standard Edition

-





SUMMARY
In Visual Studio .NET, when you add a module definition file (.def) to a project, and the project name contains an embedded space character, you may receive the following linker error messages when you build the project:

LNK1118: syntax error in 'LIBRARY' statement

-or-

LNK1141: failure during build of exports file



CAUSE
The problem occurs because the LIBRARY statement that is generated by the Visual Studio .NET IDE contains the name of the project that is not enclosed in double quotation marks (&quot;&quot;) when the module definition file is added.



STATUS
Microsoft has confirmed that this is a bug in the Microsoft products that are listed at the beginning of this article.



WORKAROUND
When the name contains an embedded space character, enclose the library name that is generated by the designer in double quotation marks for the LIBRARY statement in the module definition file (.def).



MORE INFORMATION
Any Visual C++ .NET project that is created in the Visual Studio .NET IDE generates the linker errors when the project builds a DLL. This is not true for Visual C++ MFC (Microsoft Foundation Classes) DLL projects. By default, the MFC DLL projects that are created by the IDE contain a .def file with the LIBRARY statement name enclosed in double quotation marks.

You see the linker errors for the following project templates under Visual C++ .NET projects:

Visual Studio .NET 2002

 * ATL Project
 * ATL Server Project
 * ATL Server Web Service
 * Extended Stored Procedure DLL
 * Managed C++ Class Library
 * Managed C++ Web Service
 * Win32 DLL Project under Win32 Project

Visual Studio .NET 2003

 * ASP.NET Web Service
 * ATL Project
 * ATL Server Project
 * ATL Server Web Service
 * Class Library (.NET)
 * Extended Stored Procedure DLL
 * Windows Control Library (.NET)
 * Win32 DLL Project under Win32 Project

Steps to Reproduce the Behavior
 In Visual Studio .NET, create a Visual C++ ATL Project, and then name it My Sample. Notice that the project name has an embedded space character. Add a module definition file to the project. To do this, follow these steps:  In Solution Explorer, right-click Project. Point to Add, and then click Add New Item. In the Add New Item dialog box, click DEF file (.def) under Templates.</li> Name the .def file. It does not have to be same as the project name. Click Open.</li></ol> </li>  Open the .def file in the IDE. You see the following content for the .def file. Notice the absence of the double quotation marks around the name. LIBRARY My Sample </li> Build the application. You may receive the linker errors that are described in the &quot;Symptoms&quot; section.</li></ol>

<div class="references_section">