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..."
autoconf
echo "autoheader..."
autoheader
echo "automake..."
automake --add-missing --copy
echo
echo "Now run: ./configure --prefix="
echo

Note the call to "libtoolize".

Then, in your configure.ac, add this:

AC_CONFIG_MACRO_DIR([libltdl/m4])
LT_CONFIG_LTDL_DIR([libltdl])
LT_INIT([dlopen])
LTDL_INIT([recursive])

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:

AM_CPPFLAGS = $(LTDLINCL)
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.


Follow

🐘 MastodonRSS (English), RSS (português), RSS (todos / all)


Last 10 entries


Search


Admin