hisham hm

“.la file not recognized: File format not recognized”

If you’re writing a program using Autotools (Autoconf, Automake, Libtool and friends) and start getting this error message after adding a new library dependency, this means the library in question exports its link flags using Libtool, but your program’s build is not libtoolized yet.

You need to add a call to “libtoolize” to your project. I usually use a script called autogen.sh which calls the various autotools. This is what a typical autogen.sh of mine looks like:

#!/bin/sh -e
echo "libtoolize..."
libtoolize --copy --ltdl --force
echo "aclocal..."
aclocal -I aclocal
echo "autoconf..."
echo "autoheader..."
echo "automake..."
automake --add-missing --copy
echo "Now run: ./configure --prefix="

Note the call to "libtoolize".

Then, in your configure.ac, add this:


I got this snippet from this bit of the Libtool manual. I usually add it near the top, after AC_PROG_CC and before AC_HEADER_STDC. In the end, add libltdl/Makefile to the AC_CONFIG_FILES rule. Assuming you already have Makefile and src/Makefile, it would look like this:

AC_CONFIG_FILES([Makefile src/Makefile libltdl/Makefile])

Then in your root Makefile.am, add this:

SUBDIRS = libltdl # plus any subdirs you may already have
ACLOCAL_AMFLAGS = -I libltdl/m4

and for your executable's rules (suppose it is called foo), add:

foo_LDADD = $(LIBLTDL) # plus anything else you may already have

And that's it: that's what you need so that .la files can link properly when building your executable. I don't know if that's the optimal way, but it works for me.

Add comment

Fill out the form below to add your own comments.

CAPTCHA imageReload imageAudible version of CAPTCHA-image