红联Linux门户
Linux帮助

autotools编makefile文件时,发生错误(已解决)

发布时间:2008-05-08 21:59:19来源:红联作者:yanyaohua
我用autotools编makefile文件时,发生错误:
configure: error: cannot find install-sh or install.sh in "." "./.." "./../.."


[yan@localhost ch2]$ ls
avg.c main.c
[yan@localhost ch2]$ autoscan
[yan@localhost ch2]$ mv configure.scan 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_INIT(test,1.0)
AM_INIT_AUTOMAKE(test,1.0)
AC_CONFIG_SRCDIR([main.c])
AM_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_CONFIG_FILES([makefile])
AC_OUTPUT
#######################################################
[yan@localhost ch2]$ aclocal
[yan@localhost ch2]$ autoconf
[yan@localhost ch2]$ autoheader
[yan@localhost ch2]$ vim makefile.am
#############makefile.am内容#############
AUTOMAKE_OPTIONMS=foreign
bin_PROGRAMS=test
test_SOURCES=main.c avg.c
###########################################
[yan@localhost ch2]$ ./configure

[ 本帖最后由 yanyaohua 于 2008-5-9 11:28 编辑 ]
文章评论

共有 6 条评论

  1. croosszzy 于 2009-11-24 11:30:02发表:

    路过,顺便学习一下。

  2. datou1986111 于 2009-11-23 16:20:31发表:

    爱死你了,哈哈,谢了!

  3. datou1986111 于 2009-11-23 16:16:03发表:

    ddddddddddddddd

  4. 黄富强 于 2008-05-09 14:15:51发表:

    建议设为精华
    写得不错,程序有点问题var-----写成数组AC_CONFIG_SRCDIR([avg.c])----->AC_CONFIG_SRCDIR([2_5fun_avg.c])

    [ 本帖最后由 黄富强 于 2008-5-9 14:23 编辑 ]

  5. yanyaohua 于 2008-05-09 11:28:11发表:

    1. 比如编写程序 2_5fun_avg.c ,2_5fun_sum.c,2_5main.c 和 chengji.h
    #########################
    ####2_5fun_avg.c #######
    float fun_avg(int var[],int num)
    {
    float avrg=0.0;
    int i;
    for(i=0;iavrg+=var;
    avrg/=num;
    return (avrg);
    }

    ####2_5fun_sum.c#######
    float fun_sum(int var[],int num)
    {
    float avrg=0.0;
    int i;
    for(i=0;iavrg+=var[i];
    return (avrg);
    }

    ####2_5main.c#######
    #include
    #include "chengji.h"
    int main()
    {
    int n,i;
    float avg,sum;
    printf("请输入需要统计的学生数:");
    scanf("%d",&n);
    int array[n];
    for( i=0;i{
    printf("请输入第%d学生的成绩:",i+1);
    scanf("%d",&array[i]);
    }
    sum=fun_sum(array,n);
    printf("所有的%d个学生的总成绩是: %6.2f\n",n,sum);
    avg=fun_avg(array,n);
    printf("输入的%d个学生的平均成绩是: %6.2f\n",n,avg);
    return 0;
    }
    ####chengji.h#######
    float fun_sum(int var[],int num);
    float fun_avg(int var[],int num);
    ##############################

    2.写makefile.am
    $vi makefile.am
    #####################
    AUTOMAKE_OPTIONS=foreign
    bin_PROGRAMS=2_5 //最后可执行文件名称
    2_5_SOURCES=2_5fun_avg.c 2_5fun_sum.c 2_5main.c //程序
    ########################

    3.$autoscan
    ##############################
    # -*- 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_INIT(main,1.0) //最后可执行文件名称,版本
    AM_INIT_AUTOMAKE(main,1.0) //增加这一行
    AC_CONFIG_SRCDIR([avg.c])
    AM_CONFIG_HEADER([config.h]) //C改为M

    # 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_CONFIG_FILES([makefile]) //
    AC_OUTPUT

    # -*- 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_INIT(2_5,1.0) //最后可执行文件名称,版本
    AM_INIT_AUTOMAKE(2_5,1.0) //增加这一行
    AC_CONFIG_SRCDIR([chengji.h])
    AC_CONFIG_HEADER([config.h]) //AC_改为AM_,我没改也成功

    # 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_CONFIG_FILES([makefile])
    AC_OUTPUT

    ################################################################################

    4.$aclocal

    5.$autoconf

    6.$autoheader

    7.$automake -a
    不行就 再执行一次

    8. $./configure
    9. $make
    10. $./2_5

    [[i] 本帖最后由 yanyaohua 于 2008-5-9 11:54 编辑
    ]

  6. yanyaohua 于 2008-05-09 11:24:21发表:

    搞定了