/NODEFAULTLIB(忽略库)/NODEFAULTLIB (Ignore Libraries)

/NODEFAULTLIB[library]/NODEFAULTLIB[:library]

参数Arguments

类库library
希望链接器在解析外部引用时忽略的库。A library that you want the linker to ignore when it resolves external references.

备注Remarks

/NODEFAULTLIB 选项通知链接器从其在解析外部引用时搜索的库列表中删除一个或多个默认库。The /NODEFAULTLIB option tells the linker to remove one or more default libraries from the list of libraries it searches when resolving external references.

若要创建不包含对默认库的引用的 .obj 文件,请使用 /zl (忽略默认库名称) To create an .obj file that contains no references to default libraries, use /Zl (Omit Default Library Name).

默认情况下,/NODEFAULTLIB 将在解析外部引用时搜索的库列表中删除所有默认库。By default, /NODEFAULTLIB removes all default libraries from the list of libraries it searches when resolving external references. 可选的 library 参数使你可以从其在解析外部引用时搜索的库列表中删除指定的库。The optional library parameter lets you remove a specified library from the list of libraries it searches when resolving external references. 为要排除的每个库指定一个/NODEFAULTLIB 选项。Specify one /NODEFAULTLIB option for each library you want to exclude.

链接器解析对外部定义的引用,方法是先在显式指定的库中搜索,然后在使用 /DEFAULTLIB: 选项指定的默认库中搜索,然后在 .obj 文件中命名的默认库中进行搜索。The linker resolves references to external definitions by searching first in libraries that you explicitly specify, then in default libraries specified with the /DEFAULTLIB: option, and then in default libraries named in .obj files.

/NODEFAULTLIB:在两个中同时指定相同的 名称时, 将覆盖/DEFAULTLIB:library/NODEFAULTLIB:library overrides /DEFAULTLIB:library when the same library name is specified in both.

如果在不使用 C 运行时库的情况下使用/NODEFAULTLIB 来生成程序,则可能还必须使用 /ENTRY 来指定程序中的入口点函数。If you use /NODEFAULTLIB to build your program without the C run-time library, you may have to also use /ENTRY to specify the entry-point function in your program. 有关详细信息,请参阅 CRT 库功能For more information, see CRT Library Features.

在 Visual Studio 开发环境中设置此链接器选项To set this linker option in the Visual Studio development environment

  1. 打开项目的“属性页” 对话框。Open the project's Property Pages dialog box. 有关详细信息,请参阅在 Visual Studio 中设置 C++ 编译器和生成属性For details, see Set C++ compiler and build properties in Visual Studio.

  2. 选择 "配置属性 > 链接器 > 输入" 属性页。Select the Configuration Properties > Linker > Input property page.

  3. 选择 " 忽略所有默认库 " 属性。Select the Ignore All Default Libraries property. 或者,在 " 忽略特定的默认库 " 属性中指定要忽略的库的分号分隔列表。Or, specify a semicolon-separated list of the libraries you want to ignore in the Ignore Specific Default Libraries property. " 命令行 " 属性页显示对这些属性所做的更改的影响。The Command Line property page shows the effect of the changes you make to these properties.

以编程方式设置此链接器选项To set this linker option programmatically

请参阅See also

MSVC 链接器参考MSVC linker reference
MSVC 链接器选项MSVC Linker Options