What are libtool's .la
files for? How are they used with a shared object?
It is a textual file that includes a description of the library.
It allows libtool
to create platform-independent names.
For example, libfoo
goes to:
Under 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:
/lib/libfoo.dll.a # Import library
/lib/libfoo.a # Static library
/lib/libfoo.la # libtool library
/bin/cygfoo_1.dll # DLL
Under 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.la
is the only file that is preserved between platforms by libtool
allowing to understand what happens with:
- Library dependencies
- Actual file names
- Library version and revision
Without depending on a specific platform implementation of libraries.
libtool
to link the object files (gnu.org/software/libtool/manual/html_node/Using-Automake.html) but if I want to distribute a library without .la, does it mean it will be very difficult to link with it using Cygwin or mingw? –
Bramante libtool --mode-link ${whatever_command_you_would_use_for_linking} -lfoo -L${where_libfoo.la_exists}
and it will print the linking command as debug info. In my case the static files were in .libs/ folder containing *.la file –
Circumjacent 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:
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.
I found very good explanation about .la files here 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.
© 2022 - 2024 — McMap. All rights reserved.