what is the difference between .so and .a files?

家住魔仙堡 提交于 2019-12-03 15:04:02

问题


I am trying to compile a 3rd party library( on linux) and see that it is generating libsomething.a files I have my other libraries which are .so file

But it appears that even .a is shared library and can be used just like a .so lib

So is there any difference between the two ? or they are just same with different naming convention.


回答1:


But it appears that even .a is shared library

Nope, it's a static library.

and can be used just like a .so lib

If you mean linking to it, then yes. But you can't dlopen() an .a file which you could do with an .so file.

You can always ask our old friend Uncle G to answer your questions.




回答2:


A .a file is a static library, while a .so file is a shared object dynamic library similar to a DLL on Windows.

A .a can included as part of a program during the compilation & .so can imported, while a program loads.




回答3:


When you link against the *.a, the code from the library is included in the executable itself and the executable can be run without requiring the *.a file to be present. When you link against the *.so, that is not the case and the *.so file must be present at runtime.



来源:https://stackoverflow.com/questions/12293530/what-is-the-difference-between-so-and-a-files

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