29

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?

***.lib / ***.exp
Community
  • 1
  • 1
Adam Lee
  • 24,710
  • 51
  • 156
  • 236

2 Answers2

11

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.

From MSDN

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.

From MSDN

Community
  • 1
  • 1
NullPoiиteя
  • 56,591
  • 22
  • 125
  • 143
2

From the 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.

AJM
  • 1,317
  • 2
  • 15
  • 30
NPE
  • 486,780
  • 108
  • 951
  • 1,012
  • Here is a more current link to [Working with Import Libraries and Export Files](https://learn.microsoft.com/en-us/cpp/build/reference/working-with-import-libraries-and-export-files?view=vs-2019). – Robert Bernstein Apr 05 '19 at 19:12
  • The MSDN link is now broken. Archive link: https://web.archive.org/web/20130726233212/http://msdn.microsoft.com/en-us/library/se8y7dcs(v=vs.80).aspx I would edit it in, but the queue is full at the moment. – AJM May 06 '22 at 17:06