[root@localhost test3]# cat add.h
#ifndef _ADD_H_
#define _ADD_H_

extern int add(int, int);

#endif

[root@localhost test3]# cat add.c
#include "add.h"

int add(int a, int b)
{
        return a + b;
}

[root@localhost test3]# cat main.c
#include 
#include "add.h"

int main()
{
        int a, b, c;

a = 5;
        b = 6;

c = add(a, b);

printf("c = %d\n", c);

return 0;
}

[root@localhost test3]# gcc -shared -o libadd.so add.c

1、执行autoscan
[root@localhost test3]# autoscan
[root@localhost test3]# ls
add.c  add.h  autoscan.log  configure.scan  main.c

2、编辑configure.in
[root@localhost test3]# mv configure.scan configure.in

[root@localhost test3]# cat configure.in
#                                               -*- Autoconf -*-
# Process this file with autoconf to produce a configure script.

AC_PREREQ([2.63])
AC_INIT([main], [1.0], [yww680169@126.com])
AM_INIT_AUTOMAKE(main, 1.0)
AC_CONFIG_SRCDIR([main.c])
AC_CONFIG_HEADERS([config.h])

# Checks for programs.
AC_PROG_CC

# Checks for libraries.
AC_CHECK_LIB(add, add)
# Checks for header files.
AC_CHECK_HEADERS([add.h])
# Checks for typedefs, structures, and compiler characteristics.

# Checks for library functions.

AC_OUTPUT(Makefile)

3、执行aclocal
[root@localhost test3]# aclocal

4、执行autoconf
[root@localhost test3]# autoconf

5、执行autoheader
[root@localhost test3]# autoheader

6、新建Makefile.am
[root@localhost test3]# cat Makefile.am
AUTOMAKE_OPTIONS=foreign
bin_PROGRAMS=main
main_SOURCES=main.c
main_LDADD=libadd.so

7、执行automake
[root@localhost test3]# automake
configure.in:6: required file `./install-sh' not found
configure.in:6:   `automake --add-missing' can install `install-sh'
configure.in:6: required file `./missing' not found
configure.in:6:   `automake --add-missing' can install `missing'
Makefile.am: required file `./depcomp' not found
Makefile.am:   `automake --add-missing' can install `depcomp'
[root@localhost test3]# automake --add-missing
configure.in:6: installing `./install-sh'
configure.in:6: installing `./missing'
Makefile.am: installing `./depcomp'
[root@localhost test3]# automake --add-missing

7、执行./configure
[root@localhost test3]# ./configure                              
checking for a BSD-compatible install... /usr/bin/install -c     
checking whether build environment is sane... yes                
checking for a thread-safe mkdir -p... /bin/mkdir -p             
checking for gawk... gawk                                        
checking whether make sets $(MAKE)... yes                        
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         
checking for style of include used by make... GNU
checking dependency style of gcc... gcc3
checking for add in -ladd... no
checking how to run the C preprocessor... gcc -E
checking for grep that handles long lines and -e... /bin/grep
checking for egrep... /bin/grep -E
checking for ANSI C header files... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking add.h usability... no
checking add.h presence... no
checking for add.h... no
configure: creating ./config.status
config.status: creating Makefile
config.status: creating config.h
config.status: executing depfiles commands

8、make
[root@localhost test3]# make
make  all-am
make[1]: Entering directory `/home/xiaowan/Desktop/test3'
gcc -DHAVE_CONFIG_H -I.     -g -O2 -MT main.o -MD -MP -MF .deps/main.Tpo -c -o main.o main.c
mv -f .deps/main.Tpo .deps/main.Po
gcc  -g -O2   -o main main.o libadd.so
make[1]: Leaving directory `/home/xiaowan/Desktop/test3'

9、make install
[root@localhost test3]# make install
make[1]: Entering directory `/home/xiaowan/Desktop/test3'
test -z "/usr/local/bin" || /bin/mkdir -p "/usr/local/bin"
  /usr/bin/install -c main '/usr/local/bin'
make[1]: Nothing to be done for `install-data-am'.
make[1]: Leaving directory `/home/xiaowan/Desktop/test3'

10、导出环境变量(在当前目录下执行命令需导出环境变量)
[root@localhost test3]# export LD_LIBRARY_PATH=$PWD

11、执行./main
[root@localhost test3]# ./main
c = 11

http://blog.chinaunix.net/uid-26133817-id-4281336.html

在线手册:

http://www.gnu.org/software/automake/manual/automake.html#API-Versioning

GNU自动化工具使用全过程详解,以及在线手册的更多相关文章

  1. 分区工具parted的详解及常用分区使用方法【转】

    来源:http://blog.51cto.com/zhangmingqian/1068779 分区工具parted的详解及常用分区使用方法 一.         parted的用途及说明 概括使用说明 ...

  2. 日志分析工具ELK配置详解

    日志分析工具ELK配置详解 一.ELK介绍 1.1 elasticsearch 1.1.1 elasticsearch介绍 ElasticSearch是一个基于Lucene的搜索服务器.它提供了一个分 ...

  3. 黑苹果引导工具 Clover 配置详解及Clover Configurator使用

    黑苹果引导工具 Clover 配置详解及Clover Configurator使用  2017-03-11 14:01:40 by SemiconductorKING 转自:@三个表哥   简介: 可 ...

  4. Fiddler抓取https请求 & Fiddler抓包工具常用功能详解

    Fiddler抓取https请求 & Fiddler抓包工具常用功能详解   先来看一个小故事: 小T在测试APP时,打开某个页面展示异常,于是就跑到客户端开发小A那里说:“你这个页面做的有问 ...

  5. 浏览器解析html全过程详解

    前端文摘:深入解析浏览器的幕后工作原理 关于浏览器解析html全过程详解 输入URL到浏览器接收返回的数据的整个过程 TCP报文格式详解 IP报文格式详解 Linux IO模式及 select.pol ...

  6. virtualbox centos安装增强工具和问题详解

    virtualbox centos安装增强工具和问题详解 VirtualBox 大家都习惯性把它简称为 Vbox ,比 VM 的体积小.开源.速 度快.不过在使用 VirtualBox 在虚拟机中安装 ...

  7. redis cluster管理工具redis-trib.rb详解

    redis cluster管理工具redis-trib.rb详解 来源 http://weizijun.cn/2016/01/08/redis%20cluster%E7%AE%A1%E7%90%86% ...

  8. Protobuf 文件生成工具 Prototool 命令详解

    Protobuf 文件生成工具 Prototool 命令详解 简介 Prototool 是 Protobuf 文件的生成工具, 目前支持go, php, java, c#, object c 五种语言 ...

  9. Apache性能测试工具ab使用详解~转载

    Apache自带性能测试工具ab使用详解 一. Apache的下载 1. http://www.apache.org/,进入Apache的官网 2. 将页面拖到最下方“Apache Project L ...

随机推荐

  1. 学习鸟哥的Linux私房菜笔记(14)——硬件配置与管理

    一.设备文件 Linux沿袭了Unix的风格,将所有设备看成一个文件 设备文件分为两种: 块设备文件(b):比如硬盘.光驱 字符设备文件(c):比如串口.键盘 设备文件一般存放在/dev目录下 二.常 ...

  2. Windows完成端口与Linux epoll技术简介(能看懂)

    WINDOWS完成端口编程1.基本概念2.WINDOWS完成端口的特点3.完成端口(Completion Ports )相关数据结构和创建4.完成端口线程的工作原理5.Windows完成端口的实例代码 ...

  3. Docker for Windows 安装

    原文:Docker for Windows 安装 前言: 环境:windows10专业版 64位 正文: 官方下载地址:https://hub.docker.com/editions/communit ...

  4. js 时间日期函数

    忘记从哪里拷贝过来的了,侵删 Date.prototype.format = function (format) { var date = { "M+": this.getMont ...

  5. 【codeforces 534D】Handshakes

    [题目链接]:http://codeforces.com/contest/534/problem/D [题意] n个人依次进入一个房间; 进进来的人会和房间里面没有组队的人握一次手; (这里的握手只计 ...

  6. Qt实用技巧:使用QTableView、QSqlTableMode与QSqlDatabase对数据库数据进行操作

    本文章博客地址:http://blog.csdn.net/qq21497936/article/details/78615800 Qt实用技巧:使用QTableView.QSqlTableMode与Q ...

  7. C#颜色对照使用表

    这篇文章来来源于C# Color Table,这里是我翻译的中文版本,其中已经加上了我的一些理解和注释.翻译这篇文章的原因是我在写C#程序的时候发现,C#自带的颜色种类极多(详见下表),如果没有直观的 ...

  8. 各个版本 Windows 10 系统中自带的 .NET Framework 版本

    原文各个版本 Windows 10 系统中自带的 .NET Framework 版本 Windows 名称 Windows 版本 自带的 .NET Framework 版本 Windows 10 Oc ...

  9. 手把手教你安装QT集成开发环境(操作系统为ubuntu10.04,需要先安装build-essential和libncurses5-dev)

    在安装QT集成开发工具包之前需要先安装build-essential和libncurses5-dev这两个开发工具和库,libncurses5-dev库是一个在Linux/Unix下广泛应用的图形函数 ...

  10. python3实现域名查询和whois查询

    关键字:python3 域名查询 域名查询接口 whois查询原文:http://www.cnblogs.com/txw1958/archive/2012/08/31/python3-domain-w ...