Which format does static library (*.lib) files use? Where can I find “Official” specifications of *.LIB file structure/format?

牧云@^-^@ 提交于 2019-11-27 06:46:52

问题


Just now I found that static libraries in *nix systems, in other words *.a libraries are nothing but archives of relocatables(*.o files) in ar fromat.

  1. What about static libraries(*.lib files) in windows? Which format are they in?

  2. I found an article (archived copy 1, archived copy 2) which explains *.lib file structure. But Where can I find "Official" specifications of *.lib file structure/format?

  3. Other than ar.exe of mingw is there any tool from Microsoft which extracts relocatable objects of *.lib & *.a files?

EDIT:

I wonder why I'm unable to get to this question. If there are no official specifications. Then how does the compiler ('linker' to be more correct) writers work with *.LIB files?


回答1:


I found that *.LIB file uses the ar file format.

Official Specifications: Section 7. "Archive (Library) File Format" of Microsoft Portable Executable and Common Object File Format Specification describes this format.




回答2:


mingw's ar works just fine on *.lib files - even ones created under VisualStudio.

We've actually used it in the past to pull out parts of a library we needed when it contained some other stuff we couldn't link with (due to conflicts with other libraries). Kinda hacky, but it works.



来源:https://stackoverflow.com/questions/2371531/which-format-does-static-library-lib-files-use-where-can-i-find-official

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!