Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the use of .exp and what is the difference between .lib and .dll?

During compilation and linking, what is use of .exp? What is the difference between .lib and .dll? I know that .lib will be used, while linking and .dll will be used when running the program. But what exactly is the difference between .lib and .dll?

Does .lib file not contain the code for the functions coming from .dll files? What is the need for using two separate files?

Please clarify.

like image 894
Vineel Kumar Reddy Avatar asked Apr 28 '10 05:04

Vineel Kumar Reddy


People also ask

What is the use of .LIB file?

A LIB file contains a library of information used by a specific program. It may store a variety of information, which may include functions and constants referenced by a program or actual objects, such as text clippings, images, or other media.

What is the difference between LIB and DLL?

LIB vs DLLLIB is a static library where functions and procedures can be placed and called as the application is being compiled. A DLL or Dynamic Link Library does the same function but is dynamic in a sense that the application can call these libraries during run-time and not during the compilation.

What is a .exp file?

An EXP file is a symbols export file, produced by an integrated development environment (IDE) or compiler. It contains binary information about exported data and functions. EXP files are used to link the program they were created from with another program.

Does a DLL need a lib file?

lib must be passed to the linker. The second one is explicit linking when we use the DLL by manually loading it with LoadLibrary function. In this type we don't need that . lib file, but we must put a little effort to find DLL exports, their addresses, and call these functions through pointers.


1 Answers

In the case of an import library for a DLL, the .lib file does not contain any actual code at all. It basically contains just a list of the functions in the associated DLL -- enough for the linker to embed a reference to that DLL into something linked with the library, but not much else.

A .exp file is an export file -- basically just about the same as a .lib file. It's used (at least primarily) when you have a circular dependency. For example, assume you have a DLL that acts as a plug-in for an executable. The executable supplies some exported functions for use by plug-in DLLs, but also needs to be able to call some functions in the plug-ins as well (e.g. to load and initialize a plug-in).

The DLL won't link until the executable is built to provide a .lib file -- but the executable won't link until the DLL is built to provide a .lib file. To break the dependency, you run the linker against the executable, which fails (because it can't find a .lib file for the DLL), but will produce a .exp file. You then link the DLL against the .exp file for the executable. You can then re-run link to produce the executable, using the .lib file for the DLL.

like image 189
Jerry Coffin Avatar answered Oct 10 '22 23:10

Jerry Coffin