INF: Why Error L2044 Suggests You Use /NOE

ID Number: Q80123

3.x 4.x 5.0x 5.10 5.13 5.20 | 5.0x 5.10 5.13

MS-DOS | OS/2

Summary:

When linking without /NOE, if a symbol is defined in more than one

module, the following error is given:

LINK error L2044

'symbol' : symbol multiply defined, use /NOE

This additional information is given in the documentation:

LINK found what it interprets as a public-symbol redefinition,

probably because a symbol defined in a library was redefined.

Relink with the /NOE option. If error L2025 results for the same

symbol, then this is a genuine symbol-redefinition error.

The linker issues error L2044 since it cannot tell if the redefinition

occurred due to the use of the extended dictionary or if the symbol

was genuinely redefined. If /NOE is used and the symbol is still

redefined, then it is a genuine redefinition and error L2025 will be

generated.

More Information:

The library utility, LIB.EXE, creates an extended dictionary when it

builds a library, unless LIB.EXE is invoked with the /NOE switch. The

extended dictionary contains cross-references between the modules. For

example, suppose Mod1 and Mod2 were modules in a library and that

function A() in Mod1 called function B() in Mod2. In this

relationship, Mod1 is known as the primary module and Mod2 is known as

the secondary module.

Mod1: Primary Module Mod2: Secondary Module

______________ ______________

| | | |

| A( ) | | B( ) |

| { | | { |

| B( ) | | |

| } | | } |

|______________| |______________|

Whenever Mod1 is needed, Mod2 will most likely be needed as a support

module, since a function in Mod1 relies on a function in Mod2.

The linker can take advantage of this information to speed up the link

process. The linker finds all symbols in the object files first and

uses them to resolve the external references. If any symbols remain

unresolved, link searches the libraries for those symbols and pulls in

the modules that contain them.

Suppose that a program that contains a call to the function A(), but

not A() itself, is compiled and linked with a library containing Mod1

and Mod2 above. After the object is searched, A() is still unresolved.

LINK will find A() defined in Mod1 and pull that module in. If the

extended dictionary is used, Mod2 will be pulled in as well, so that

the call to B() will be automatically resolved. If the extended

dictionary is not used, LINK will notice that B() is a new symbol and

will need to search the libraries to see if it can be resolved.

In general, if there are many libraries to be searched, the process of

resolving the symbols in the primary modules will take much longer

than if the secondary modules had been pulled in with the

corresponding primary modules.

The following example is a case where use of the extended dictionary

will cause a symbol redefinition.

Primary Modules Secondary Modules

______________ ______________

| | | |

| X( ) | | Z( ) |

Library1: | { | | { |

| Z( ) | | |

| } | | } |

|______________| |______________|

______________ ______________

| | | |

| Y( ) | | Z( ) |

Library2: | { | | { |

| Z( ) | | |

| } | | } |

|______________| |______________|

Suppose that a program that contains calls to X() and Y(), but does

not define Z(), is compiled and linked with Library1 and Library2. If

the extended dictionary is used, both of the secondary modules will be

pulled in, resulting in a redefinition of Z(). If the extended

dictionary is not used, LINK will resolve Z() by pulling in the first

module it finds that defines Z() (note that libraries will be searched

in the order that they are specified on the command line). Therefore,

using /NOE will eliminate the problem.

Also, suppose that a program that contains a call to Z() and defines

Z() is compiled and linked with Library1. If the extended dictionary

is used, the secondary module will be pulled in, resulting in a

redefinition of Z(). If the extended dictionary is not used, function

X's call to Z() will be resolved with the Z() defined in the program.

Therefore, using /NOE will eliminate the problem.

Additional reference words: 3.00 3.01 3.02 3.04 3.05 3.06 3.51 3.55

3.60 3.61 3.64 3.65 3.69 4.06 4.07 4.10 5.01.20 5.01.21 5.02 5.03

5.05 5.10 5.13 5.20