Automake error './ltmain.sh' not found

2020-05-14 10:20发布

问题:

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?

回答1:

In an autoconf/automake/libtool project you have to invoke:

  • 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).

You'll most likely want to add a bootstrap script to each of your projects, that invokes all of those tools, in this order. Or you could be lazy and just invoke autoreconf -i and see if that works for your project.

After (and while) you have working Makefiles generated by the configure script, autotools takes care of itself; that is, if you edit configure.ac, or any Makefile.am, the correct tools above will be invoked again to keep everything updated, by simply running make. Just be careful to not create a syntax error in the Makefile.am files, otherwise you might end up with broken Makefiles, causing make to refuse to run - in which case you have to run the bootstrap script (or autoreconf) manually.

EDIT:

The automake manual says this about aclocal:

aclocal is expected to disappear.

And further down:

From the user point of view, aclocal's removal might turn out to be painful. There is a simple precaution that you may take to make that switch more seamless: never call aclocal yourself. Keep this guy under the exclusive control of autoreconf and Automake’s rebuild rules.

So there you have it: use autoreconf -i to be future-proof, unless you have a very good reason to use the tools directly.