Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why are LIB files beasts of such a duplicitous nature?

I'm trying to understand this LIB file business on Microsoft Windows, and I've just made a discovery that will - I hope - dispel the confusion that hitherto has prevented me from getting a clear grasp of the issue. To wit, LIB files are not the one kind of file that their file extension suggests they are.

:: cd "C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Lib"  :: lib /nologo /list Ad1.Lib obj\i386\activdbgid.obj obj\i386\activscpid.obj obj\i386\ad1exid.obj obj\i386\dbgpropid.obj obj\i386\dispexid.obj  :: lib /nologo /list oledb.lib o:\winmain.obj.x86fre\enduser\…\oledb\uuid\objfre\i386\oledbiid.obj o:\winmain.obj.x86fre\enduser\…\oledb\uuid\objfre\i386\oledbnewiid.obj o:\winmain.obj.x86fre\enduser\…\oledb\uuid\objfre\i386\cmdtreeiid.obj o:\winmain.obj.x86fre\enduser\…\oledb\uuid\objfre\i386\oledbdepiid.obj  :: lib /nologo /list AdvAPI32.Lib | sort | uniq -c     731 ADVAPI32.dll 

The first two examples contain object files (appearing as relative or absolute paths when displayed by the lib.exe utility). The third example, however, only contains 731 references to a DLL. (I guess lib.exe isn't designed to display more useful information for this kind of file.)

Some contain object files, and they are static libraries. Others contain symbols, and they are import libraries. (There's a short explanation here.)

So static libraries appear to be the equivalents of .a files on Linux, and DLLs appear to map to .so files on Linux. (By the way, how would import libraries fit into this Windows/Linux equivalence picture?)

Now I'm wondering why this is so? Why did Microsoft decide to give import libraries the same file extension as static libraries? (I understand that historically, static libraries were first, like primitive forms of life preceded more complex forms.) Why wouldn't they say, okay, here's these new kind of libraries, they shall be referred to as import libraries, and they shall bear the file extension .ILB (or whatever)?

like image 862
Lumi Avatar asked Jun 21 '11 07:06

Lumi


People also ask

What are lib files used for?

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's a .LIB file?

A lib file is just a collection of related obj files, much like putting obj files in a directory. That is essentially what a lib file is, a library of obj files. For a static link, all of the obj files that an executable uses are combined into one file.

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.

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

Because they are libraries. Why invent a whole new vendor-specific extension for what is exactly the same thing as their already-vendor-specific libraries?

like image 163
Blindy Avatar answered Nov 05 '22 07:11

Blindy