PRB: DLL Is Not Unloaded When Using LINK from C 6.00

ID Number: Q65606

3.00

WINDOWS

Summary:

SYMPTOMS

After updating to the version of LINK that is included with the

Microsoft C Compiler version 6.0, Dynamic-Link Libraries (DLLs)

are not unloaded when all applications using the DLLs have exited.

CAUSE

The DLL is not unloaded because the LIBRARY name in the .DEF file

is not capitalized.

RESOLUTION

In the version of LINK that is included with the Microsoft C

Compiler version 6.0, the .DEF file's LIBRARY name is NOT

automatically converted to uppercase. If a .DEF file's LIBRARY

statement is not capitalized, the Windows KERNEL will not unload

the library unless it is explicitly loaded and unloaded with

LoadLibrary() and FreeLibrary(). Earlier versions of LINK

automatically converted the LIBRARY name to uppercase; therefore,

this problem did not occur.

More Information:

Included below is a list of the versions of LINK that are available,

and the version messages they display. The list also describes some of

the major differences between the new releases of LINK. The following

versions of LINK can be used for Windows EXCEPT for the version

shipped with MS-DOS. This is because Windows requires a

"Segmented-Executable" linker.

LINK shipped with MS-DOS - NOT for Windows development.

Microsoft Overlay Linker version 3.65

Copyright Microsoft Corp 1983-1988. All rights reserved.

Link4 shipped with Windows version 2.x SDK (Software Development Kit).

Microsoft Segmented-Executable Linker version 5.01.17

Copyright Microsoft Corp 1984-1988. All rights reserved.

Link(5) shipped with C Compiler versions 5.x.

Microsoft Segmented-Executable Linker version 5.01.21

Copyright Microsoft Corp 1984-1988. All rights reserved.

Link(6) shipped with C Compiler version 6.0.

Microsoft Segmented-Executable Linker version 5.10

Copyright Microsoft Corp 1984-1990. All rights reserved.

The main difference between LINK4 and LINK(5) is that in LINK4 the

.EXE file is automatically flagged as being a Windows application;

LINK(5) instead requires that the following be explicitly stated in

the .DEF file:

EXETYPE WINDOWS

The main difference between LINK(5) and LINK(6) is that in LINK(6) the

.DEF file's LIBRARY name is NOT converted to uppercase automatically.

If a .DEF file's LIBRARY statement is not capitalized, the Windows

KERNEL will not unload the library unless it is explicitly loaded and

unloaded with LoadLibrary() and FreeLibrary(). For example:

LIBRARY MyDll --> link(5) --> MYDLL (correct)

LIBRARY MyDll --> link(6) --> MyDll (NOT correct)

Also, do not use an underline as part of the filename.