步骤:
aclocal
autoconf
autoheader
automake --add-missing
问题1:
configure.ac:18: error: possibly undefined macro: AC_PROG_LIBTOOL
If this token and others are legitimate, please use m4_pattern_allow.
See the Autoconf documentation.
autoreconf: /usr/bin/autoconf failed with exit status: 1
centos下:yum install libtool
问题2:
configure.ac:188:required file 'ltmain.sh'
解决方法:
autoreconf -ivf
一、生成configure过程中各文件之间的关系图
二、详细介绍
autoscan: 扫描源代码以搜寻普通的可移植性问题,比如检查编译器,库,头文件等,生成文件configure.scan,它是configure.ac的一个雏形。
aclocal:根据已经安装的宏,用户定义宏和acinclude.m4文件中的宏将configure.ac文件所需要的宏集中定义到文件 aclocal.m4中。aclocal是一个perl 脚本程序,它的定义是:“aclocal - create aclocal.m4 by scanning configure.ac”
automake:将Makefile.am中定义的结构建立Makefile.in,然后configure脚本将生成的Makefile.in文件转换 为Makefile。如果在configure.ac中定义了一些特殊的宏,比如AC_PROG_LIBTOOL,它会调用libtoolize,否则它 会自己产生config.guess和config.sub
autoconf:将configure.ac中的宏展开,生成configure脚本。这个过程可能要用到aclocal.m4中定义的宏。
三、实例
1.测试代码(定义两个文件hello.h和hello.c)
/*hello.c*/ #include <iostream> #include "hello.h" using namespace std; int main() { CHello a; return 0; }
/*hello.h*/ #ifndef __HELLO_H__ #define __HELLO_H__ #include<iostream> using namespace std; class CHello { public: CHello(){ cout<<"Hello!"<<endl;} ~CHello(){ cout<<"Bye!"<<endl;} }; #endif
2.操作步骤
(1)安装依赖的包
[root@bogon autoconfig]# yum -y install automake autoconf
automake包括:aclocal、automake等
autoconf包括:autoscan、autoco