Posted on 2013-04-01 15:53
菜鸟想学飞 阅读(567)
评论(0) 编辑 收藏 引用
1.建立一个目录.
mkidr test
2.建立一个测试文件
vi main.cpp
1 #include <iostream>
2
3 int main(int argc, char* agrv[])
4 {
5 std::cout << "hello!" << std::endl;
6 return 0;
7 }
3.创建configure.ac文件
autoscan
提示configure.ac不存在,但是会生成一个configure.scan
mv configure.scan configure.ac
vi configure.ac修改为如下
1 # -*- Autoconf -*-
2 # Process this file with autoconf to produce a configure script.
3
4 AC_PREREQ(2.59)
5 AC_INIT([loki], [1.0], [])
6 AM_INIT_AUTOMAKE
7 AC_CONFIG_SRCDIR([main.cpp])
8 AC_CONFIG_HEADER([config.h])
9 AC_CONFIG_FILES([Makefile])
10
11 # Checks for programs.
12 AC_PROG_CXX
13
14 # Checks for libraries.
15
16 # Checks for header files.
17
18 # Checks for typedefs, structures, and compiler characteristics.
19
20 # Checks for library functions.
21 AC_OUTPUT
4.创建相关文件
touch AUTHORS ChangeLog NEWS README
5.编写Makefile.am
vi Makefile.am
1 noinst_PROGRAMS = loki
2 loki_SOURCES = main.cpp
6.
autoreconf -i
7.
./configure
8. 配置完工,使用make即可看到编译出的执行文件loki
make
./loki
要了解具体为什么要这样做,请看这篇教程http://www.freesoftwaremagazine.com/books/autotools_a_guide_to_autoconf_automake_libtool