AutoConf和AutoMake使用出错求助
2个回答
展开全部
###***如果你在m-net.arbornet.net没有Linux账户,可以输入newuser建立一个
一、编写一个hello.c的源代码文档:
$ mkdir ~/abc
$ cd ~/abc
$ touch hello.c
$ vi hello.c
# include "stdio.h"
int main(int argc, char** argv)
{
printf("Hello, GNU! ");
return 0;
}
二、 生成configure.scan并编辑为configure.in:
$ autoscan → cp configure.scan configure.in→vi configure.in →
###***原始的configure.in文档:
# -*- Autoconf -*-
# Process this file with autoconf to produce a configure script.
AC_PREREQ(2.61) ←
AC_INIT(FULL-PACKAGE-NAME, VERSION, BUG-REPORT-ADDRESS) ←
AC_CONFIG_SRCDIR([hello.c])
AC_CONFIG_HEADER([config.h])
# Checks for programs.
AC_PROG_CC
# Checks for libraries.
# Checks for header files.
# Checks for typedefs, structures, and compiler characteristics.
# Checks for library functions.
AC_OUTPUT ←
----------------------------------------------------------------------------------------------------------------------
###***修改后的configure.in文档:
# -*- Autoconf -*-
# Process this file with autoconf to produce a configure script.
#AC_PREREQ(2.61) →
###***使用aclocal19命令会报错:
###***configure.in:4: error: Autoconf version 2.61 or higher is required
###***configure.in:4: the top level
###***autom4te259: /usr/local/bin/gm4 failed with exit status: 63
###***aclocal19: autom4te259 failed with exit status: 63
###***将上面的代码注释掉即可排除错误
AC_INIT(hello.c)
AC_CONFIG_SRCDIR([hello.c])
AC_CONFIG_HEADER([config.h])
AC_CONFIG_FILES([Makefile])
AM_INIT_AUTOMAKE(hello, 1.0)
# Checks for programs.
AC_PROG_CC
# Checks for libraries.
# Checks for header files.
# Checks for typedefs, structures, and compiler characteristics.
# Checks for library functions.
AC_OUTPUT (Makefile)
三、 使用aclocal和autoconf生成aclocal.m4和configure文件:
$ aclocal119 → autoconf →touch Makefile.am →
# -*- Makefile.am -*-
AUTOMAKE_OPTIONS= foreign
bin_PROGRAMS= hello
hello_SOURCES= hello.c
四、 使用autoheader
$ autoheader →
五、 使用automake生成Makefile.in文件:
$ automake19 --add-missing
六、 使用configure生成最终Makefile:
$ ./configure --prefix=/home/XXX/hello →
checking for gcc... gcc
checking for C compiler default output file name... a.out
checking whether the C compiler works... yes
checking whether we are cross compiling... no
checking for suffix of executables...
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
configure: creating ./config.status
config.status: creating config.h
./configure: line 3448: Makefile: command not found
###***configure出现错误,按提示修改configure文件:
$ vi ./configure →
###*** 原始的configure文档内容:
###*** 3444
# Use ||, not &&, to avoid exiting from the if with $? = 1, which
###*** 3445
# would make configure fail if this is the last instruction.
###*** 3446
$ac_cs_success || { (exit 1); exit 1; }
###*** 3447
fi
###*** 3448
(Makefile) ←
--------------------------------------------------------------------------------------------------------------------------
###***修改后的configure文档内容:
###*** 3448
# (Makefile)
###*** 将3448行的代码注释掉即可。
七、 最终make前用ls检查文件:
$ ls →
Makefile config.h configure.scan
Makefile.am config.h.in depcomp
Makefile.in config.log hello.c
aclocal.m4 config.status install-sh
autom4te.cache configure missing
autoscan-2.61.log configure.in stamp-h1
八、 开始编译并运行测试:
$ Make
$ Make install
$ ~/hello/bin/hello
Hello, GNU! [XXXX@m-net ~/abc]$
一、编写一个hello.c的源代码文档:
$ mkdir ~/abc
$ cd ~/abc
$ touch hello.c
$ vi hello.c
# include "stdio.h"
int main(int argc, char** argv)
{
printf("Hello, GNU! ");
return 0;
}
二、 生成configure.scan并编辑为configure.in:
$ autoscan → cp configure.scan configure.in→vi configure.in →
###***原始的configure.in文档:
# -*- Autoconf -*-
# Process this file with autoconf to produce a configure script.
AC_PREREQ(2.61) ←
AC_INIT(FULL-PACKAGE-NAME, VERSION, BUG-REPORT-ADDRESS) ←
AC_CONFIG_SRCDIR([hello.c])
AC_CONFIG_HEADER([config.h])
# Checks for programs.
AC_PROG_CC
# Checks for libraries.
# Checks for header files.
# Checks for typedefs, structures, and compiler characteristics.
# Checks for library functions.
AC_OUTPUT ←
----------------------------------------------------------------------------------------------------------------------
###***修改后的configure.in文档:
# -*- Autoconf -*-
# Process this file with autoconf to produce a configure script.
#AC_PREREQ(2.61) →
###***使用aclocal19命令会报错:
###***configure.in:4: error: Autoconf version 2.61 or higher is required
###***configure.in:4: the top level
###***autom4te259: /usr/local/bin/gm4 failed with exit status: 63
###***aclocal19: autom4te259 failed with exit status: 63
###***将上面的代码注释掉即可排除错误
AC_INIT(hello.c)
AC_CONFIG_SRCDIR([hello.c])
AC_CONFIG_HEADER([config.h])
AC_CONFIG_FILES([Makefile])
AM_INIT_AUTOMAKE(hello, 1.0)
# Checks for programs.
AC_PROG_CC
# Checks for libraries.
# Checks for header files.
# Checks for typedefs, structures, and compiler characteristics.
# Checks for library functions.
AC_OUTPUT (Makefile)
三、 使用aclocal和autoconf生成aclocal.m4和configure文件:
$ aclocal119 → autoconf →touch Makefile.am →
# -*- Makefile.am -*-
AUTOMAKE_OPTIONS= foreign
bin_PROGRAMS= hello
hello_SOURCES= hello.c
四、 使用autoheader
$ autoheader →
五、 使用automake生成Makefile.in文件:
$ automake19 --add-missing
六、 使用configure生成最终Makefile:
$ ./configure --prefix=/home/XXX/hello →
checking for gcc... gcc
checking for C compiler default output file name... a.out
checking whether the C compiler works... yes
checking whether we are cross compiling... no
checking for suffix of executables...
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
configure: creating ./config.status
config.status: creating config.h
./configure: line 3448: Makefile: command not found
###***configure出现错误,按提示修改configure文件:
$ vi ./configure →
###*** 原始的configure文档内容:
###*** 3444
# Use ||, not &&, to avoid exiting from the if with $? = 1, which
###*** 3445
# would make configure fail if this is the last instruction.
###*** 3446
$ac_cs_success || { (exit 1); exit 1; }
###*** 3447
fi
###*** 3448
(Makefile) ←
--------------------------------------------------------------------------------------------------------------------------
###***修改后的configure文档内容:
###*** 3448
# (Makefile)
###*** 将3448行的代码注释掉即可。
七、 最终make前用ls检查文件:
$ ls →
Makefile config.h configure.scan
Makefile.am config.h.in depcomp
Makefile.in config.log hello.c
aclocal.m4 config.status install-sh
autom4te.cache configure missing
autoscan-2.61.log configure.in stamp-h1
八、 开始编译并运行测试:
$ Make
$ Make install
$ ~/hello/bin/hello
Hello, GNU! [XXXX@m-net ~/abc]$
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询