现在很多项目都在使用GUI编译器,Kdevelop\Eclipse等等,诚然它给我们提供了极大地便利,但我们仍需要简单了解编译的过程。本文旨在简单叙述由源码(*.cpp & *.h)经过编译得到可执行文件的过程,以及对生成的中间文件做一个简单的讲解,后面给出一个example。

相关tips & explanations:

1. autoscan:扫描源代码以搜寻普通的可移植性问题,比如检查编译器,库,头文件等,生成文件configure.scan,它是configure.ac的一个雏形。

过程:your source files --> [autoscan*] --> [configure.scan] --> configure.ac

2. aclocal:根据已经安装的宏,用户定义宏和acinclude.m4文件中的宏将configure.ac文件所需要的宏集中定义到文件aclocal.m4中。

aclocal是一个perl脚本程序,它的定义是:"aclocal - create aclocal.m4 by scanning configure.ac"

3. automake:automake将Makefile.am中定义的结构建立Makefile.in。

然后configure脚本将生成的Makefile.in文件转换 为Makefile。如果在configure.ac中定义了一些特殊的宏,比如AC_PROG_LIBTOOL,它会调用libtoolize,否则它 会自己产生config.guess和config.sub

4. autoconf:将configure.ac中的宏展开,生成configure脚本。这个过程可能要用到aclocal.m4中定义的宏。

5. ./configure的过程

6. make过程

[autoconfig.h]—.
                    +-----> make* ----->程序

Never mind, That's not a problem~, there is nothing to be afraid of, cause the following example I provided will show you the guide. perhaps you should type the commands one by one for better understanding.

Example:

在/home/panda/目录下vi一个hello.cpp文件(当然,你的[*.cpp&*.h]都可以放在这里,但必须保证没有语法上的错误),并complie它:

>>>>cd /home/panda/hello/

>>>>vi hello.cpp/*编写源文件hello.cpp*/

[CODE]

#include<iostream>

using namespace std;

int main()

{

cout<<"Hello,RoboCup."<<endl;

return 0;

}

[/CODE]

>>>>autoscan

>>>>mv configure.scan configure.in

>>>>vi configure.in

/*已经生成了configure.scan,autoscan.log*/

/*将configure.scan 修改为 configure.in,最后修改的内容如下*/

[CODE]

#-*- Autoconf -*-

# Process this file with autoconf to produce a configure script.

AC_PREREQ(2.59)

AC_INIT(FULL-PACKAGE-NAME, VERSION, BUG-REPORT-ADDRESS)

AC_CONFIG_SRCDIR([hello.cpp])

#AC_CONFIG_HEADER([config.h])

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)

[/CODE]

>>>>aclocal/*生成 aclocal.m4 和 autom4te.cache (生成aclocal.m4的过程中涉及到configure.in)*/

>>>>ls

>>>> aclocal.m4 autom4te.cache autoscan.log configure.in hello.cpp

>>>>antoconf/*生成 configure (根据 configure.in, 和 aclocal.m4)*/

>>>>ls

>>>>aclocal.m4 autom4te.cache autoscan.log configure configure.in hello.cpp

>>>>vi Makefile.am/*编写Makefile.am*/

>>>>vi Makefile.am

/*编写Makefile.am*/

[CODE]

AUTOMAKE_OPTIONS= foreign

bin_PROGRAMS= hello

hello_SOURCES= hello.cpp

[/CODE]

>>>>automake

>>>>automake --add-missing/*生成 Makefile.in, depcomp, install-sh, 和 missing (根据 Makefile.am, 和 aclocal.m4)*/

>>>>ls

>>>>aclocal.m4 autom4te.cache autoscan.log configure configure.in depcomp hello.cpp install-sh Makefile.am Makefile.in missing

>>>>configure/*Makefile, config.log, 和 config.status*/

/*红色表示在终端中输入的命令,斜体表示源码*/

至此大功告成。

现在看不明白,或者不是很清楚都没有关系,只做了解就好,可以将本文保留下来,随着你们学习的深入,等到时机成熟的时候再作参考,便会对Linux下C++的编译过程会理解的更加透彻。

Good Luck!

文档下载链接:http://download.csdn.net/detail/klcf0220/7703221

configure.*和Makefile.*之间的关系的更多相关文章

  1. Kbuild、Kconfig、make menuconfig、.config、Makefile之间的关系

    今天突发奇想,想在这里分享下比喻分析Kbuild ---->去饭店吃饭的过程.   1.Kconfig --->饭店的菜单 2.条件编译选项--->菜单中的每一盘菜,可以选择这个菜的 ...

  2. 关于gcc、glibc和binutils模块之间的关系,以及在现有系统上如何升级的总结

    http://blog.csai.cn/user1/265/archives/2005/2465.html 一.关于gcc.glibc和binutils模块之间的关系 1.gcc(gnu collec ...

  3. 【转】关于gcc、glibc和binutils模块之间的关系

    原文网址:http://www.mike.org.cn/articles/linux-about-gcc-glibc-and-binutils-the-relationship-between-mod ...

  4. .NET Core与.NET Framework、Mono之间的关系

    随着微软的.NET开源的推进,现在在.NET的实现上有了三个.NET Framework,Mono和.NET Core.经常被问起Mono的稳定性怎么样,后续Mono的前景如何,要回答这个问题就需要搞 ...

  5. .NET Core 和 .NET Framework 之间的关系

    引用一段描述:Understanding the relationship between .NET Core and the .NET Framework. .NET Core and the .N ...

  6. 9.Configure One-to-One(配置一对一关系)【Code-First系列】

    现在,开始学习怎么配置一对一的关系,众所周知,一对一的关系是:一个表中的主键,在另外一个表中,同时是主键和外键[实际上是一对零或者一对一]. 请注意:一对一的关系,在MS SQL Server中,技术 ...

  7. 实体之间的关系【Entity Relationships】(EF基础系列篇9)

    Here, you will learn how entity framework manages the relationships between entities. Entity framewo ...

  8. php CGI、Fastcgi、PHP-FPM的详细介绍与之间的关系

    以下PHP CGI.Fastcgi.PHP-FPM的一些信息归纳和汇总----->详细介绍与之间的关系 一:CGI是干嘛的?CGI是为了保证web server传递过来的数据是标准格式的 web ...

  9. [转] valuestack,stackContext,ActionContext.之间的关系

    三者之间的关系如下图所示: ActionContext  一次Action调用都会创建一个ActionContext  调用:ActionContext context = ActionContext ...

随机推荐

  1. Git与GitHub学习笔记(七)Windows 配置Github ssh key

    前言 SSH是建立在应用层和传输层基础上的安全协议,其目的是专为远程登录会话和其他网络服务提供安全性的保障,用过SSH远程登录的人都比较熟悉,可以认为SSH是一种安全的Shell.SSH登录是需要用户 ...

  2. 065、容器在Weave中如何通信和隔离?(2019-04-08 周一)

    参考https://www.cnblogs.com/CloudMan6/p/7491831.html   在host2上执行如下命令:       weave launch host1_ip   必须 ...

  3. impala系列: 基本命令和jdbc连接

    --======================= 使用impala-shell 登录 --======================= impala-shell --auth_creds_ok_i ...

  4. Js点击按钮下载文件到本地(兼容多浏览器)

    实现点击 用纯 js(非jquery)  下载文件到本地 自己尝试,加网上找了好久未果,如: window.open(url)   location.href=url   form表单提交   ifr ...

  5. 一次针对多台服务器交互式主机命令采集Python脚本编写

    [环境介绍]   系统环境:Linux + Python 2.7.10(监控主机)   [背景描述] 需求:每次节假日或者重要时间时,需要对数据库主机信息进行检查,比如主机空间使用率之类.有时候需要执 ...

  6. ASP.NET MVC 5 笔记

    1.   MVC 的常用特性 1)   System.Web.Mvc.ActionNameAttribute Ø  该特性用于将当前 Action 名称,改为一个指定的 Action 名称,路由匹配时 ...

  7. MQTT学习笔记

    因为工作需要,了解了一下MQTT.顺便记下来,现在还不会用. 一.概述 MQTT(Message Queuing Telemetyr Transport  消息队列遥测传输协议):基于发布/订阅(Pu ...

  8. 割点判断+luogu 3469 POI2008 BLO

    1.根节点,有2棵及以上子树 2.非根节点,有子节点dfn[u]<=low[v] #include <bits/stdc++.h> #define N 1000050 using n ...

  9. python之import模块及包的调用

    模块概念 在Python中,一个.py文件就称之为一个模块(Module).使用模块组织代码,最大的好处是大大提高了代码的可维护性 模块一共三种:python标准库.第三方模块.应用程序自定义模块. ...

  10. linux命令去掉_bak

    有时候有很多_bak文件,想把_bak去掉,使用linux命令 find ./ -name "*_bak" | awk -F "_" '{print $1}' ...