开发者

Why are LIB files beasts of such a duplicitous nature?

开发者 https://www.devze.com 2023-03-14 18:55 出处:网络
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 gra

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 ap开发者_运维问答pear 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)?


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?

0

精彩评论

暂无评论...
验证码 换一张
取 消