Automake error './ltmain.sh' not found

user1345414 picture user1345414 · Mar 24, 2014 · Viewed 20.2k times · Source

I've installed mingw and msys by using mingw-get-setup.exe. I've also installed Autotools(autoconf, automake,m4,libtool) into C:\/opt/autotools.

When I run automake, the following error always occurs:

configure.ac:11: error: required file './ltmain.sh' not found

If I copy ltmain.sh from libtool’s installed tree, execution will finish normally.

How can I configuure automake to find ltmain.sh without copying?

Answer

DanielKO picture DanielKO · Mar 25, 2014

In an autoconf/automake/libtool project you need to run:

  • libtoolize: this copies/links a few support scripts, including ltmain.sh (which is the main component of libtool).
  • aclocal: this looks up all m4 macros that your configure script will need, and make a local copy for easier access.
  • autoheader: optional, if you want to use config.h/AC_CONFIG_HEADERS, otherwise all the test result macros will be inlined when you call the compiler.
  • autoconf: to expand all the macros used by configure.ac into the configure script.
  • automake: to convert all the Makefile.am into Makefile.in templates. You probably want to invoke this with --add-missing so additional support scripts can be linked/copied to your project (such as compile, missing, depcomp, test-driver, etc).

Don't worry about running each tool. Just invoke autoreconf -i and it'll run the tools that are needed. Add -v if you want to see what tools is being executed. To avoid mistakes, just put a script like this at the root of your project:

#!/bin/bash -x
mkdir -p m4
exec autoreconf --install "$@"

Users that checkout/clone the project directly from the source repository will need to run this ./bootstrap script at least once. This is not needed if the user got a tarball distribution.

Automake can take fairly good care of itself; it'll re-invoke the above tools when needed, when you run make. But if you generate a broken Makefile, you'll need to invoke ./bootstrap and ./configure again to generate new Makefiles.