XLL+ Class Library (6.3)

Linker Error LNK2005

After saving a project, the linker fails with error LNK2005

Symptoms

After adding a new source file or library to an XLL+ project and saving the project, the following linker error occurs:

LNK2005: symbol multiply defined

In particular, this can occur in a project which previously linked perfectly.

Summary

  1. The Microsoft run-time libraries use weak external linkage to resolve the linking of some important functions, including new, delete and DllMain().
    Optionally, see MSDN articles Q148652 and Q72651 for more details of this technique and its implications, in order to gain a deeper understanding of what is occurring.
  2. To be sure of curing the problem, put the appropriate XLL+ run-time library at the start of the list of the Additional Dependencies which can be found in the Linker / Input page of the Project Properties window. A list of the libraries required for the various builds is below.

Procedure for fixing the problem

Determine the name of the appropriate XLL+ run-time library, using the list below. In the Link / Input page of the Project Settings dialog, put the name of the library at the start of the Additional Dependencies field. Note that you will need to do this for both configurations, Debug and Release, and that each configuration will use a different library.

In the Additional Dependencies field add the required libraries at the beginning (i.e. left-hand side) of the list. The required libraries are as follows. Ensure that you select the correct libraries for the builds you are using.

Build Configuration Character set Library
MFC Debug ANSI xlllibd.lib
MFC Release ANSI xlllibr.lib
MFC Debug Unicode xlllibdw.lib
MFC Release Unicode xlllibrw.lib
STL Debug ANSI xlllibsd.lib
STL Release ANSI xlllibsr.lib
STL Debug Unicode xlllibsdw.lib
STL Release Unicode xlllibsrw.lib