暂时用的方法如下:
工程代码结构是
[root@localhost pro1]# tree
.
|-- demos
| |-- fvs_binarize.c
| |-- fvs_createtestimages.c
| |-- fvs_direction.c
| |-- fvs_enhancer.c
| |-- fvs_mask.c
| |-- fvs_minutia.c
| `-- fvs_thinner.c
|-- include
| |-- export.h
| |-- file.h
| |-- floatfield.h
| |-- fvs.h
| |-- fvstypes.h
| |-- histogram.h
| |-- image.h
| |-- imagemanip.h
| |-- img_base.h
| |-- import.h
| |-- matching.h
| `-- minutia.h
|-- src
| |-- export.c
| |-- file.c
| |-- floatfield.c
| |-- histogram.c
| |-- image.c
| |-- imagemanip.c
| |-- img_base.c
| |-- img_base.c~
| |-- img_enhance.c
| |-- img_morphology.c
| |-- img_thin.c
| |-- import.c
| |-- matching.c
| |-- minutia.c
| `-- version.c
`-- tags
3 directories, 35 files
目标是要生成demos文件夹下一个应用: fvs_enhance。
1、在源码的根目录下运行autoscan,生成autoscan.log configure.scan
2、改configure.scan,并重命名为configure.in内容如下:
# -*- Autoconf -*-
# Process this file with autoconf to produce a configure script.
AC_PREREQ(2.61)
AC_INIT(fvs_enhancer.c) #此句需要自己更改。测试编译的工程路径下是否存在此文件,以确定生成的configure路径是否正确
AC_CONFIG_SRCDIR([include/minutia.h])
AC_CONFIG_HEADER([config.h])
AM_INIT_AUTOMAKE(fvs_enhancer,1.0) #此句需要自己添加,如果缺少此句后面运行aclocal不会生成aclocal.m4文件。生成的软件的名称和版本号
# Checks for programs.
AC_PROG_CC
# Checks for libraries.
# Checks for header files.
AC_HEADER_STDC
AC_CHECK_HEADERS([inttypes.h stdint.h stdlib.h string.h])
# Checks for typedefs, structures, and compiler characteristics.
AC_C_CONST
AC_HEADER_STDBOOL
AC_C_INLINE
AC_TYPE_INT16_T
AC_TYPE_INT32_T
AC_TYPE_INT8_T
AC_TYPE_SIZE_T
AC_TYPE_UINT16_T
AC_TYPE_UINT32_T
AC_TYPE_UINT8_T
# Checks for library functions.
AC_FUNC_MALLOC
AC_CHECK_FUNCS([memset sqrt])
AC_OUTPUT([Makefile]) #这句需要自己修改,以生成Makefile文件
3、运行aclocal,正常的话会生成aclocal.m4 autom4te.cache
4、运行autoconf,生成configure
5、运行autoheader,它负责生成config.h.in文件。该工具通常会从“acconfig.h”文件中复制用户附加的符号定义,因为我的这个工程中没有附加符号定义,所以不需要创建“acconfig.h”文件。
6、编写Makefile.am文件,内容如下:
AUTOMAKE_OPTIONS=foreign #由于GNU对自己发布的软件有严格的规范,比如必须附带许可证声明文件COPYING等,否则automake执行时会报错。automake提供了三种软件等级:foreign、gnu和gnits,让用户选择采用,默认等级为gnu。在本例使用foreign等级,它只检测必须的文件。
bin_PROGRAMS=fvs_enhancer fvs_binarize #两个可执行文件名称
fvs_enhancer_SOURCES=demos/fvs_enhancer.c include/fvs.h src/image.c include/image.h src/floatfield.c include/floatfield.h src/import.c include/import.h src/img_base.c include/img_base.h src/histogram.c include/histogram.h src/imagemanip.c include/imagemanip.h src/img_enhance.c include/img_enhance.h src/export.c include/export.h src/img_morphology.c
fvs_binarize_SOURCES=demos/fvs_enhancer.c
include/fvs.h src/image.c include/image.h src/floatfield.c
include/floatfield.h src/import.c include/import.h src/img_base.c
include/img_base.h src/histogram.c include/histogram.h src/imagemanip.c
include/imagemanip.h src/img_enhance.c include/img_enhance.h
src/export.c include/export.h src/img_morphology.c
7、运行automake --add-missing
根据Makefile.am生成Makefile.in
8、运行./configure 生成Makefile
更改此Makefile中CFLAGS,加入自己的头文件目录路径;更改LDFLAGS,加入要连接的第三方库的路径
出现如下错误的原因是Makefile中LDFLAGS没有加入ImageDilate所在库的路径
gcc -g -O2 -I/home/dongjiajing/softwaretmp/pro1/include -I/usr/local/include/ImageMagick -lm -lMagickCore -lMagickWand -o fvs_enhancer fvs_enhancer.o image.o floatfield.o import.o img_base.o histogram.o imagemanip.o img_enhance.o export.o
imagemanip.o: In function `FingerprintGetMask':
/home/dongjiajing/softwaretmp/pro1/src/imagemanip.c:595: undefined reference to `ImageDilate'
以后就可以make,或者make install等等。
至于aclocal、autoconf、automake的关系见图,其中带*表示命令,红色代表要自己写的文件,白色是中间生成文件,橙色表示要改写的生成文件。
每个文件更详细的信息请参考GNU编码规范,中文翻译如下:
阅读(2222) | 评论(0) | 转发(0) |