C++ *.exp 文件有什么作用?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/13667443/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
What does *.exp file do?
提问by Adam Lee
Possible Duplicate:
what is use of .exp and what is the difference between .lib and .dll
when I link with some c++ library, for each *.lib, it is associated with a *.exp file. what does *.exp do?
当我链接某个 C++ 库时,对于每个 *.lib,它都与一个 *.exp 文件相关联。*.exp 有什么作用?
***.lib / ***.exp
回答by NullPoiиteя
Export (.exp) files contain information about exported functions and data items. When LIB creates an import library, it also creates an .exp file. You use the .exp file when you link a program that both exports to and imports from another program, either directly or indirectly. If you link with an .exp file, LINK does not produce an import library, because it assumes that LIB already created one.
导出 (.exp) 文件包含有关导出函数和数据项的信息。当 LIB 创建一个导入库时,它也会创建一个 .exp 文件。当您链接一个直接或间接从另一个程序导出和导入的程序时,您可以使用 .exp 文件。如果使用 .exp 文件链接,LINK 不会生成导入库,因为它假定 LIB 已经创建了一个。
You can use LIB with the /DEF option to create an import library and an export file. LINK uses the export file to build a program that contains exports (usually a dynamic-link library (DLL)), and it uses the import library to resolve references to those exports in other programs.
Note that if you create your import library in a preliminary step, before creating your .dll, you must pass the same set of object files when building the .dll, as you passed when building the import library.
In most situations, you do not need to use LIB to create your import library. When you link a program (either an executable file or a DLL) that contains exports, LINK automatically creates an import library that describes the exports. Later, when you link a program that references those exports, you specify the import library.
However, when a DLL exports to a program that it also imports from, whether directly or indirectly, you must use LIB to create one of the import libraries. When LIB creates an import library, it also creates an export file. You must use the export file when linking one of the DLLs.
您可以使用带有 /DEF 选项的 LIB 来创建导入库和导出文件。LINK 使用导出文件来构建包含导出(通常是动态链接库 (DLL))的程序,并使用导入库解析对其他程序中这些导出的引用。
请注意,如果您在初步步骤中创建导入库,则在创建 .dll 之前,您必须在构建 .dll 时传递与构建导入库时传递的对象文件集相同的对象文件集。
在大多数情况下,您不需要使用 LIB 来创建您的导入库。当您链接包含导出的程序(可执行文件或 DLL)时,LINK 会自动创建一个描述导出的导入库。稍后,当您链接引用这些导出的程序时,您可以指定导入库。
但是,当 DLL 导出到它也从中导入的程序时,无论是直接还是间接,您都必须使用 LIB 来创建导入库之一。当 LIB 创建一个导入库时,它也会创建一个导出文件。链接 DLL 之一时必须使用导出文件。
回答by NPE
From the MSDN:
从MSDN:
Export (.exp) files contain information about exported functions and data items. When LIB creates an import library, it also creates an .exp file. You use the .exp file when you link a program that both exports to and imports from another program, either directly or indirectly. If you link with an .exp file, LINK does not produce an import library, because it assumes that LIB already created one. For details about .exp files and import libraries, see Working with Import Libraries and Export Files.
导出 (.exp) 文件包含有关导出函数和数据项的信息。当 LIB 创建一个导入库时,它也会创建一个 .exp 文件。当您链接一个直接或间接从另一个程序导出和导入的程序时,您可以使用 .exp 文件。如果使用 .exp 文件链接,LINK 不会生成导入库,因为它假定 LIB 已经创建了一个。有关 .exp 文件和导入库的详细信息,请参阅使用导入库和导出文件。