Libtool 版本不匹配错误

在 Ubuntu 10.04上使用 kdevelopment 3.5构建我的应用程序时,我得到了以下错误:

libtool: Version mismatch error. This is libtool 2.2.6 Debian-2.2.6a-4, but the
libtool: definition of this LT_INIT comes from libtool 2.2.6b.
libtool: You should recreate aclocal.m4 with macros from libtool 2.2.6 Debian-2.2.6a-4
libtool: and run autoconf again.
make[2]: *** [wktools4] Error 63
make[2]: Target `all' not remade because of errors.
make[1]: *** [all-recursive] Error 1
make: *** [all] Error 2
*** Exited with status: 2 ***

从哪里可以获得所需的 libtool 版本,或者如何重新创建 aclocal.m4?

78353 次浏览

Try running aclocal

Try running

autoreconf --force --install
./configure
make

in the root directory of your project.

If that doesn't work, try running make maintainer-clean first and then go to step 1.

If that still doesn't work, run make maintainer-clean, then delete every generated file in the root directory of your project; including aclocal.m4, any m4 directory, any autom4te.cache directory, configure, Makefile.in, config.h, config.h.in, config.status, libtool, aclocal.m40, etc. Then go to step 1.

Why this works: libtool and aclocal.m4 are both files that are generated by your build system. If they are out of sync (generated by different versions of the build tools), then you get this error. Normally that shouldn't happen, but an example of something that can cause it is when you check in generated files to source control.

What this solution does is delete and regenerate all the autogenerated files. Once they're erased and regenerated, they can't be out of sync anymore.

Try

autoreconf -i

The -i option is important.

maybe you have installed two libtools of different version. Try to apt-get remove all (until you get nothing, when you type which libtool in the command line), then apt-get install the one you like.

I solve that uninstalling system's libtool and installing from upstream: git clone git://git.savannah.gnu.org/libtool.git

sudo apt-get install texinfo autoconf automake make
./bootstrap
./configure
make
sudo make install

None of the above worked.

Then this worked:

autoconf -f
./configure
make

None of the above worked. After I deactivated the conda environment, it worked:

source deactivate

If you are using Anaconda, then this could be due to libtool and autoconf from different sources. You can check this by executing

which libtool

which autoconf

My libtool was from conda and autoconf was a system package. Uninstalled autoconf and installed it again using conda

apt remove -y autoconf (Ubuntu/Debian)

conda install -c anaconda autoconf

Note: You may need to install automake too.

conda install -c anaconda automake

I also encounter this issue. In my case, in the output of ./autogen.sh, there is:

libtoolize: You should add the contents of the following files to 'aclocal.m4': libtoolize: '/aclocal/libtool.m4' libtoolize: '/aclocal/ltoptions.m4' libtoolize: '/aclocal/ltversion.m4' libtoolize: Consider adding 'AC_CONFIG_MACRO_DIRS([m4])' to configure.ac, libtoolize: and rerunning libtoolize and aclocal. libtoolize: Consider adding '-I m4' to ACLOCAL_AMFLAGS in Makefile.am.

I just append the content the three *.m4 files under /aclocal/ to the aclocal.m4 file:

cat <a path>/aclocal/libtool.m4 <a path>/aclocal/ltoptions.m4 <a path>/aclocal/ltversion.m4 >> aclocal.m4

then make.

here is the error:

libtool: Version mismatch error.  This is libtool 2.4.2 Debian-2.4.2-1.11, but the
libtool: definition of this LT_INIT comes from libtool 2.4.6.
libtool: You should recreate aclocal.m4 with macros from libtool 2.4.2 Debian-2.4.2-1.11
libtool: and run autoconf again.

None of the above worked.

Then this worked:

wget http://ftpmirror.gnu.org/libtool/libtool-2.4.6.tar.gz -O /root/libtool-2.4.6.tar.gz
tar xzvf /root/libtool-2.4.6.tar.gz -C /root
cp -f /usr/share/libtool/build-aux/ltmain.sh /usr/share/libtool/build-aux/ltmain_sh
cp -f /root/libtool-2.4.6/build-aux/ltmain.sh /usr/share/libtool/build-aux/ltmain.sh


autoreconf -fi
./configure
make

I also use custom include directories for autoconf and autoreconf, like autoreconf -I ./m4. So it happened that an outdated ltversion.m4 accidentially was sitting inside one of those custom includes. This caused exactly the same error here. I solved it by removing the outdated ltversion.m4 file.