抱歉,您的浏览器无法访问本站
本页面需要浏览器支持(启用)JavaScript
了解详情 >

linux 下C/C++ 生成Configure 和Makefile

前提:

automake

简要步骤

  1. 编写test.c

  2. 运行autoscan

  3. 运行mv configure.scan configure.ac

  4. 修改configure.ac中内容

    
    # -*- Autoconf -*-
    # Process this file with autoconf to produce a configure script.
     
    AC_PREREQ([2.69])
    AC_INIT(test, 1.0, sizaif@mail.com)
    AC_CONFIG_SRCDIR([test.cpp])
    AC_CONFIG_HEADERS([config.h])
    AM_INIT_AUTOMAKE # 增加
    # Checks for programs.
    AC_PROG_CXX
    AC_PROG_CC
     
    # Checks for libraries.
     
    # Checks for header files.
     
    # Checks for typedefs, structures, and compiler characteristics.
    AC_TYPE_SIZE_T
     
    # Checks for library functions.
    AC_CONFIG_FILES([Makefile])
    
  5. 运行aclocal

  6. 创建Makefile.am

    AUTOMAKE_OPTIONS=foreign # 固定写法
    bin_PROGRAMS=test # 生成的可执行文件名称
    test_SOURCES=test.c # 可执行文件名称_SOURCES
  7. 运行automake --add-missing

  8. 运行autoconf 生成configure 文件

  9. 执行./configure就可以得到Makefile , 以及config.h文件

评论吧

0  字
评论
Powered by Waline v1.6.0


本站总访问量为 访客数为

鲁 ICP 备 20018157 号-1
Copyright 2021 - 2022 sizaif. All Rights Reserved