.so文件和.a文件之间的区别?

时间:2021-11-22 03:28:12

I have read that .so is a dynamic library file and .a is a static library file.

我读过.so是一个动态库文件,.a是一个静态库文件。

While building openssl i gave the option ./Configure no-shared and it created a lot of .a files.

在构建openssl时我给了选项./Configure no-shared,它创建了很多.a文件。

So, my question is will the other packages like apache will be able to use .a files from openssl?

所以,我的问题是像apache这样的其他软件包是否可以使用openssl中的.a文件?

for example libcrypto.a,

例如libcrypto.a,

someone please advice me if im going enirely through wrong path.

如果我正走错路,有人请建议我。

3 个解决方案

#1


9  

Basically the static library can be compiled into another application at link time. In your example Apache could use libcrypto.a during build time and include it in the Apache httpd application.

基本上,静态库可以在链接时编译到另一个应用程序中。在您的示例中,Apache可以在构建期间使用libcrypto.a并将其包含在Apache httpd应用程序中。

A dynamic .so library can be loaded and unloaded at runtime and you have a better flexibility to change what Apache should support without recompiling the Apache binaries.

动态.so库可以在运行时加载和卸载,您可以更灵活地更改Apache应该支持的内容,而无需重新编译Apache二进制文件。

Using Apache as example the dynamic loading of .so files are described in the Dynamic Shared Object (DSO) section in the documentation. You can also find links to the installation section which describe how to include static libraries at build time.

以Apache为例,文档中的动态共享对象(DSO)部分描述了.so文件的动态加载。您还可以找到安装部分的链接,这些链接描述了如何在构建时包含静态库。

There is a good question about this that could be good to read, and that provide mote details in the subject.

关于这一点有一个很好的问题,可以很好地阅读,并提供主题的微尘细节。

Difference between shared objects (.so), static libraries (.a), and DLL's (.so)?

共享对象(.so),静态库(.a)和DLL(.so)之间的区别?

#2


1  

If A.a is static library and two different programs want to use it. A.a is created two times for each program. while If A.so is dynamic library than two programs access same file. Its mean that you are using reference in library.

如果A.a是静态库,则两个不同的程序想要使用它。 A.a为每个程序创建两次。而如果A.so是动态库,则两个程序访问同一个文件。它的意思是你在库中使用引用。

If your library is going to be shared among several executables(like apache and openssl), it often makes sense to make it dynamic to reduce the size of the executables. Otherwise, definitely make it static.

如果您的库将在几个可执行文件(如apache和openssl)之间共享,那么通常可以使其动态化以减小可执行文件的大小。否则,绝对要让它静止。

In your case you must create dynamic library

在您的情况下,您必须创建动态库

#3


0  

Please read - http://www.yolinux.com/TUTORIALS/LibraryArchives-StaticAndDynamic.html.

请阅读 - http://www.yolinux.com/TUTORIALS/LibraryArchives-StaticAndDynamic.html。

It is a very good tutorial with example.

这是一个非常好的教程示例。

you will learn -

  1. what is static library (.a) and how to make it.
  2. 什么是静态库(.a)以及如何制作它。
  3. what is shared library (.so) and how to make it.
  4. 什么是共享库(.so)以及如何制作它。
  5. difference with .ddl (windows os)
  6. 与.ddl(windows os)的区别

#1


9  

Basically the static library can be compiled into another application at link time. In your example Apache could use libcrypto.a during build time and include it in the Apache httpd application.

基本上,静态库可以在链接时编译到另一个应用程序中。在您的示例中,Apache可以在构建期间使用libcrypto.a并将其包含在Apache httpd应用程序中。

A dynamic .so library can be loaded and unloaded at runtime and you have a better flexibility to change what Apache should support without recompiling the Apache binaries.

动态.so库可以在运行时加载和卸载,您可以更灵活地更改Apache应该支持的内容,而无需重新编译Apache二进制文件。

Using Apache as example the dynamic loading of .so files are described in the Dynamic Shared Object (DSO) section in the documentation. You can also find links to the installation section which describe how to include static libraries at build time.

以Apache为例,文档中的动态共享对象(DSO)部分描述了.so文件的动态加载。您还可以找到安装部分的链接,这些链接描述了如何在构建时包含静态库。

There is a good question about this that could be good to read, and that provide mote details in the subject.

关于这一点有一个很好的问题,可以很好地阅读,并提供主题的微尘细节。

Difference between shared objects (.so), static libraries (.a), and DLL's (.so)?

共享对象(.so),静态库(.a)和DLL(.so)之间的区别?

#2


1  

If A.a is static library and two different programs want to use it. A.a is created two times for each program. while If A.so is dynamic library than two programs access same file. Its mean that you are using reference in library.

如果A.a是静态库,则两个不同的程序想要使用它。 A.a为每个程序创建两次。而如果A.so是动态库,则两个程序访问同一个文件。它的意思是你在库中使用引用。

If your library is going to be shared among several executables(like apache and openssl), it often makes sense to make it dynamic to reduce the size of the executables. Otherwise, definitely make it static.

如果您的库将在几个可执行文件(如apache和openssl)之间共享,那么通常可以使其动态化以减小可执行文件的大小。否则,绝对要让它静止。

In your case you must create dynamic library

在您的情况下,您必须创建动态库

#3


0  

Please read - http://www.yolinux.com/TUTORIALS/LibraryArchives-StaticAndDynamic.html.

请阅读 - http://www.yolinux.com/TUTORIALS/LibraryArchives-StaticAndDynamic.html。

It is a very good tutorial with example.

这是一个非常好的教程示例。

you will learn -

  1. what is static library (.a) and how to make it.
  2. 什么是静态库(.a)以及如何制作它。
  3. what is shared library (.so) and how to make it.
  4. 什么是共享库(.so)以及如何制作它。
  5. difference with .ddl (windows os)
  6. 与.ddl(windows os)的区别