.so和.a文件有什么区别?

时间:2022-07-21 13:24:27

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

我正在尝试编译一个第三方库(在linux上),并看到它正在生成libsomething。一个文件,我有我的其他库。so文件

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

但似乎连a都是共享库,可以像so lib一样使用

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

那么这两者之间有什么区别吗?或者它们只是相同的命名惯例。

3 个解决方案

#1


17  

But it appears that even .a is shared library

但似乎a也是共享库

Nope, it's a static library.

不,它是一个静态库。

and can be used just like a .so lib

可以像。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.

如果你的意思是链接到它,那么是的。但是不能使用.so文件来打开.a文件。

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

你可以让我们的老朋友G叔叔回答你的问题。

#2


21  

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

. A文件是一个静态库,而.so文件是一个共享对象动态库,类似于Windows上的DLL。

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

A . A可以在编译过程中作为程序的一部分被包含进来& .so可以在程序加载时被导入。

#3


15  

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.

当你链接到*。a,库中的代码包含在可执行文件本身中,可执行文件可以在不需要*的情况下运行。一份文件。当你链接到*。所以,情况不是这样的。所以文件必须在运行时出现。

#1


17  

But it appears that even .a is shared library

但似乎a也是共享库

Nope, it's a static library.

不,它是一个静态库。

and can be used just like a .so lib

可以像。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.

如果你的意思是链接到它,那么是的。但是不能使用.so文件来打开.a文件。

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

你可以让我们的老朋友G叔叔回答你的问题。

#2


21  

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

. A文件是一个静态库,而.so文件是一个共享对象动态库,类似于Windows上的DLL。

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

A . A可以在编译过程中作为程序的一部分被包含进来& .so可以在程序加载时被导入。

#3


15  

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.

当你链接到*。a,库中的代码包含在可执行文件本身中,可执行文件可以在不需要*的情况下运行。一份文件。当你链接到*。所以,情况不是这样的。所以文件必须在运行时出现。