BUG: You receive "LNK1118" and "LNK1141" errors when the project name contains a space character (814421)



The information in this article applies to:

  • Microsoft Visual C++ .NET (2003)
  • Microsoft Visual C++ .NET (2002)

VisualStudio7:571556

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 ("") 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

  1. 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.
  2. Add a module definition file to the project. To do this, follow these steps:
    1. In Solution Explorer, right-click Project.
    2. Point to Add, and then click Add New Item.
    3. In the Add New Item dialog box, click DEF file (.def) under Templates.
    4. Name the .def file. It does not have to be same as the project name. Click Open.
  3. 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
  4. Build the application. You may receive the linker errors that are described in the "Symptoms" section.

REFERENCES

For additional information about the linker error LNK1118, see the following MSDN Web site:For additional information about the linker error LNK1141, see the following MSDN Web site:

Modification Type:MinorLast Reviewed:1/5/2006
Keywords:kbDesigner kbAppDev kbBug KB814421 kbAudDeveloper kbAudITPRO