GNU自动化工具使用全过程详解,以及在线手册
2017-02-27 18:28
483 查看
[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
#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
相关文章推荐
- Web自动化框架LazyUI使用手册(4)--控件抓取工具Elements Extractor详解(批量抓取)
- Web自动化框架LazyUI使用手册(4)--控件抓取工具Elements Extractor详解(批量抓取)
- Web自动化框架LazyUI使用手册(3)--单个xpath抓取插件详解(selenium元素抓取,有此插件,便再无所求!)
- 自动化运维工具Ansible部署详解与基本使用
- java项目使用log4j工具类(非web项目)以及log4j.properties文件详解
- Gradle中打jar包的方法,Gradle 自动化构建工具,Android Studio 中 Gradle 的使用方法,AndroidStudio使用过程中遇到的bug
- 使用openssl工具来验证服务器证书以及握手过程
- APP自动化框架LazyAndroid使用手册(4)--测试模板工程详解
- 网络协议分析工具Wireshark的使用、用Wireshark观察ARP协议以及ping命令的工作过程分析以太网报文格式
- APP自动化框架LazyAndroid使用手册(4)--测试模板工程详解
- 详解Android/IOS平台下抓包工具使用以及抓取API接口
- Android内存优化详解以及内存分析工具MAT的使用
- Web自动化框架LazyUI使用手册(3)--单个xpath抓取插件详解(selenium元素抓取,有此插件,便再无所求!)
- MySQL存储过程和函数以及游标使用详解
- gnuradio安装指南——详解ubuntu16.04下使用脚本安装gnuradio&uhd全过程
- 为Android应用增加渠道信息 自动化不同渠道的打包过程的使用详解
- 基于C++自动化编译工具的使用详解
- 自动化运维工具ansible部署以及使用
- APP自动化框架LazyAndroid使用手册(4)--测试模板工程详解
- ansible自动化运维工具使用详解