/Zl (Omit Default Library Name)


The latest version of this topic can be found at -Zl (Omit Default Library Name).

Omits the default C runtime library name from the .obj file. By default, the compiler puts the name of the library into the .obj file to direct the linker to the correct library.




For more information on the default library, see Use Run-Time Library.

You can use /Zl to compile .obj files you plan to put into a library. Although omitting the library name saves only a small amount of space for a single .obj file, the total space saved is significant in a library that contains many object modules.

This option is an advanced option. Setting this option removes certain C Runtime library support that may be required by your application, resulting in link-time errors if your application depends on this support. If you use this option you must provide the required components in some other way.

Use /NODEFAULTLIB (Ignore Libraries). to direct the linker to ignore library references in all .obj files.

For more information, see CRT Library Features.

When compiling with /Zl, _VC_NODEFAULTLIB is defined. For example:

// vc_nodefaultlib.cpp  
// compile with: /Zl  
void Test() {  
   #ifdef _VC_NODEFAULTLIB  
      int i;  
   int i;   // C2086  

To set this compiler option in the Visual Studio development environment

  1. Open the project's Property Pages dialog box. For details, see How to: Open Project Property Pages.

  2. Click the C/C++ folder.

  3. Click the Advanced property page.

  4. Modify the Omit Default Library Names property.

To set this compiler option programmatically

See Also

Compiler Options
Setting Compiler Options