Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

What is .LIB/.DEF

Posted on 1997-05-16
1
Medium Priority
?
1,849 Views
Last Modified: 2010-02-09
I'm an experienced Delphi programmer, and I've just started programming Borland C++ Builder. Right now I'm programming this C++ DLL. Then I wonder: What is a .LIB-file, what is a .DEF-file (I understand that my DLL should be shipped with these files, or???), and how do I make these files, do I have to make these files at all?

/Martin Ahler, Denmark
0
Comment
Question by:ahler
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 

Accepted Solution

by:
Shrif earned 200 total points
ID: 1163434
When you give someone your DLL file, there are two ways that they can use it in their own application.  In either case, they will be "loading" your DLL from their application.  DLL's can be loaded "implicitly" and "explicitly".  When a DLL is loaded explicitly, the user uses the Windows API calls LoadLibrary, GetProcAddress and FreeLibrary directly to: load the DLL, obtain function pointers to the DLL's functions and then free the DLL.  This is called explicit loading because the calling program must explicitly call LoadLibrary, GetProcAddress and FreeLibrary in order to use the DLL.  Implicit loading is when the DLL is loaded by the operating system on behalf of the application.  When the user launches the application, the operating system automatically knows what DLL's the application requires.  This is because the application has the list of required DLL's inside of its header's "import" list.  You can view a DLL's import list by using the DUMPBIN or TDUMP utility.  How does the import list get there?  It gets there because the application linked to the DLL's import library, which is a file that has the .LIB extension and the same name as the DLL.  As far as the linker is concerned, an .LIB is just another library.  But an "import" library is a special kind of library in that it doesn't have the actual code of the DLL but only forwarding addresses to point to the .DLL file.  The .LIB file is used so that the calling application's linker will resolve references to the functions in the DLL.  When you ship a DLL to a customer, you should also ship the DLL's import library along with your DLL.  If your customer is a C/C++ user, they will want this library so that they can link to your DLL implicitly.  The .Lib file is created automatically when link the DLL.  When the .DLL is created by your compiler, the .LIB file is created along with it.  A .DEF file, on the other hand, is not shipped with the DLL.  It is used by the author of the DLL to indicate which of the functions in the DLL are to be exported to the outside world.  A .DEF file is a handle coded text file listing those files that the DLL author wishes to export.  A .DEF file is added to a DLL project just like a source file is.  A .DEF file may also be specified on the command line to the linker.  A .DEF file is an input file to the linker.  Those functions that are exported, end up listed in the DLL header's "export" list.  You can view the exports section of a DLL by using the DUMPBIN or TDUMP utility.  Depending on how a DLL or an EXE is constructed, the DLL's or EXE's import and export lists may be viewed from Windows 95 or Windows NT's Explorer by right-clicking on the file and selecting "Quick View"

0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

  Included as part of the C++ Standard Template Library (STL) is a collection of generic containers. Each of these containers serves a different purpose and has different pros and cons. It is often difficult to decide which container to use and …
Introduction This article is a continuation of the C/C++ Visual Studio Express debugger series. Part 1 provided a quick start guide in using the debugger. Part 2 focused on additional topics in breakpoints. As your assignments become a little more …
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question