PRB: ATL Project Named "ATL" Fails to Build (198018)



The information in this article applies to:

  • The Microsoft Active Template Library (ATL) 3.0, when used with:
    • Microsoft Visual C++ .NET (2002)
    • Microsoft Visual C++, 32-bit Enterprise Edition 6.0
    • Microsoft Visual C++, 32-bit Professional Edition 6.0
    • Microsoft Visual C++, 32-bit Learning Edition 6.0
    • Microsoft Visual C++ .NET (2003)

This article was previously published under Q198018

SYMPTOMS

When you build an ATL project with the name 'ATL' you will

C2370: 'LIBID_ATLLib' : redefinition; different storage class c:\program files\microsoft visual studio\vc98\atl\include\atlbase.h(79) : see declaration of 'LIBID_ATLLib'

The project can be an inproc server, local server or service and the project name's case does not matter.


In Visual Studio .NET you receive the following error message:
ATL_i.obj : error LNK2005: _LIBID_ATLLib already defined in stdafx.obj ATL_i.obj : warning LNK4006: _LIBID_ATLLib already defined in stdafx.obj; second definition ignored
Creating library Debug/ATL.lib and object Debug/ATL.exp Debug/ATL.dll : fatal error LNK1169: one or more multiply defined symbols found

CAUSE

When you create a ATL project with the name 'ATL', the type library is give a name ATLLib and the midl generated header files generates a GUID named LIBID_ATLLib. This GUID name is already used in the ATL header files and so the redefinition error. ATL uses the GUID name for the registrar object and the control containment code.

RESOLUTION

  1. In the <project_name>.idl file change the name of the library from
ATLLib to something else.

  1. Do not use 'ATL' for your project name.

MORE INFORMATION

Steps to Reproduce Behavior



  1. In the Visual C++ IDE click on 'File | New' menu.
  2. In the resulting dialog, click on 'Project' tab and select 'ATL COM
AppWizard'.
  1. In the 'Project Name' edit box, type the name 'ATL' and click on 'OK'
button.
  1. In the 'ATL COM AppWizard' choose any option and build the project. You
should see the above error.

Modification Type:MajorLast Reviewed:9/12/2003
Keywords:kbprb KB198018