开发者

What's the difference between object file and static library(archive file)?

Seems archiv开发者_Go百科e file can be generated from object file:

ar rvs libprofile.a profile.o

What's the difference between object file and archive file?

It seems to me that both can be used with gcc directly,e.g.:

gcc *.c profile.o or gcc *.c libprofile.a

What's the difference?


The static library is a collection of one or more object files, with an index to allow rapid searching. There are some minor differences in how the compiler deals with them. With an object file you link like this:

gcc f1.o f2.o -o myexe

with libraries you can also do that:

gcc f1.o libf2.a -o myexe

or you can use shorthand:

gcc d1.o -lf2 -L. -o myexe

Also, gcc will ALWAYS link .o files, but it will only search libraries and link from them if there are undefined names still to resolve.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜