Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
300 views
in Technique[技术] by (71.8m points)

c - 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 SDKsWindowsv7.0ALib"

:: lib /nologo /list Ad1.Lib
obji386activdbgid.obj
obji386activscpid.obj
obji386ad1exid.obj
obji386dbgpropid.obj
obji386dispexid.obj

:: lib /nologo /list oledb.lib
o:winmain.obj.x86freenduser…oledbuuidobjfrei386oledbiid.obj
o:winmain.obj.x86freenduser…oledbuuidobjfrei386oledbnewiid.obj
o:winmain.obj.x86freenduser…oledbuuidobjfrei386cmdtreeiid.obj
o:winmain.obj.x86freenduser…oledbuuidobjfrei386oledbdepiid.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)?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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?


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...