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

- 30,738
- 21
- 105
- 131

- 7,275
- 12
- 44
- 57
-
1Also http://stackoverflow.com/q/12237282/632951 – Pacerier Jun 26 '15 at 03:51
3 Answers
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.

- 30,738
- 21
- 105
- 131

- 31,019
- 21
- 127
- 215
-
8so how to you turn the .la file to a platform specific shared lib file, like libfoo.la -> libfoo.so.* – theactiveactor Dec 31 '09 at 15:39
-
7You can't libfoo.la holds only meta information, i.e. in libfoo.la (textual file) written where should you find libfoo.so.x.y.z – Artyom Dec 31 '09 at 20:48
-
4Does it mean that in order to generate .la file, I need to use libtool (e.g. from automake)? One can rely on `libtool` to link the object files (http://www.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? – dma_k Jun 01 '10 at 14:22
-
In case that anyone want to disable this version stuff, you can use -avoid-version in your _la_LDFLAGS, instead of -version-info – laishiekai Aug 08 '18 at 23:13
-
2@theactiveactor as .la file holds metadata, it must have static library somewhere. To find that, You can run `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 – Jenil Mewada Nov 30 '20 at 09:22
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.

- 7,068
- 2
- 36
- 40
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.

- 379
- 6
- 15