Linux libtool 的 .la 文件有什么用?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/1238035/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-03 17:36:04  来源:igfitidea点击:

What are libtool's .la file for?

linuxlibrarieslibtool

提问by chappar

What are libtool's .lafiles for? How are they used with a shared object?

libtool 的.la文件有什么用?它们如何与共享对象一起使用?

采纳答案by Artyom

It is a textual file that includes a description of the library.

它是一个包含库描述的文本文件。

It allows libtoolto create platform-independent names.

它允许libtool创建与平台无关的名称。

For example, libfoogoes to:

例如,libfoo转到:

Under Linux:

在 Linux 下:

/lib/libfoo.so       # Symlink to shared object
/lib/libfoo.so.1     # Symlink to shared object
/lib/libfoo.so.1.0.1 # Shared object
/lib/libfoo.a        # Static library
/lib/libfoo.la       # 'libtool' library

Under Cygwin:

Cygwin 下

/lib/libfoo.dll.a    # Import library
/lib/libfoo.a        # Static library
/lib/libfoo.la       # libtool library
/bin/cygfoo_1.dll    # DLL

Under Windows MinGW:

在 Windows MinGW 下:

/lib/libfoo.dll.a    # Import library
/lib/libfoo.a        # Static library
/lib/libfoo.la       # 'libtool' library
/bin/foo_1.dll       # DLL

So libfoo.lais the only file that is preserved between platforms by libtoolallowing to understand what happens with:

libfoo.la通过libtool允许了解以下情况发生的情况,在平台之间保留的唯一文件也是如此:

  • Library dependencies
  • Actual file names
  • Library version and revision
  • 库依赖
  • 实际文件名
  • 库版本和修订

Without depending on a specific platform implementation of libraries.

不依赖于库的特定平台实现。

回答by Thomas Leonard

According to http://blog.flameeyes.eu/2008/04/14/what-about-those-la-files, they're needed to handle dependencies. But using pkg-config may be a better option:

根据http://blog.flameeyes.eu/2008/04/14/what-about-those-la-files,它们需要处理依赖项。但是使用 pkg-config 可能是更好的选择:

In a perfect world, every static library needing dependencies would have its own .pc file for pkg-config, and every package trying to statically link to that library would be using pkg-config --static to get the libraries to link to.

在完美的世界中,每个需要依赖项的静态库都有自己的 pkg-config .pc 文件,并且每个试图静态链接到该库的包都将使用 pkg-config --static 来获取要链接的库。

回答by Rak

I found very good explanation about .la files here http://openbooks.sourceforge.net/books/wga/dealing-with-libraries.html

我在这里找到了关于 .la 文件的很好的解释 http://openbooks.sourceforge.net/books/wga/dealing-with-libraries.html

Summary (The way I understood): Because libtool deals with static and dynamic libraries internally (through --diable-shared or --disable-static) it creates a wrapper on the library files it builds. They are treated as binary library files with in libtool supported environment.

总结(我理解的方式):因为 libtool 在内部处理静态和动态库(通过 --diable-shared 或 --disable-static),它在它构建的库文件上创建了一个包装器。在 libtool 支持的环境中,它们被视为二进制库文件。