.o files vs .a files

前端 未结 6 596
离开以前
离开以前 2021-01-30 16:20

What is the difference between these two file types. I see that my C++ app links against both types during the construction of the executable.

How to build .a files? li

6条回答
  •  醉酒成梦
    2021-01-30 16:23

    D Shawley's answer is good, I just wanted to add a couple of points because other answers reflect an incomplete understanding of what's going on.

    Keep in mind that archive files (.a) are not restricted to containing object files (.o). They may contain arbitrary files. Not often useful, but see dynamic linker dependenciy info embedded in an archive for a stupid linker trick.

    Also notice that object files (.o) are not necessarily the result of a single compilation unit. It is possible to partially link several smaller object files into a single larger file.

    http://www.mihaiu.name/2002/library_development_linux/ -- search in this page for "partial"

提交回复
热议问题