AC_CHECK_LIB(库名称,需要库中的函数,[假如找到,[假如没找到]])
在这个宏中的[库名称]实在编译时 -l 选项后面的名称,如数学库 -lm 就用 m 就行了。在例子中,假如找到了库,就在编译选项中添加 -lm 选项。
还是如上一篇中所述的那样,执行aclocal和autoconf命令,然后再创建并编辑Makefile.am文档内容如下:
AUTOMAKE_OPTIONS=foreign
bin_PROGRAMS=hello
hello_SOURCES=hello.c pubfun.c pubfun.h
Makefile.am文档和上一篇中相比就增加了源代码的数量,其他都没有改变。
然后再执行automake --add-missing即可。信息如下:
[root@leaf hello-1.0]# ./configure
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for gawk... gawk
checking whether make sets $(MAKE)... yes
checking for gcc... gcc
checking for C compiler default output... 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 ANSI C... none needed
checking for style of include used by make... GNU
checking dependency style of gcc... gcc3
checking for sin in -lm... yes
checking for pthread_create in -lpthread... yes
configure: creating ./config.status
config.status: creating Makefile
config.status: executing depfiles commands
[root@leaf hello-1.0]# make
source='hello.c' object='hello.o' libtool=no \
depfile='.deps/hello.Po' tmpdepfile='.deps/hello.TPo' \
depmode=gcc3 /bin/sh ./depcomp \
gcc -DPACKAGE_NAME=\"\" -DPACKAGE_TARNAME=\"\" -DPACKAGE_VERSION=\"\"
-DPACKAGE_STRING=\"\" -DPACKAGE_BUGREPORT=\"\" -DPACKAGE=\"hello\" -DVERSION=\"1.0\" -I. -I. -I. -O2 -c `test -f 'hello.c' || echo './'`hello.c source='pubfun.c' object='pubfun.o' libtool=no \ depfile='.deps/pubfun.Po' tmpdepfile='.deps/pubfun.TPo' \ depmode=gcc3 /bin/sh ./depcomp \
gcc -DPACKAGE_NAME=\"\" -DPACKAGE_TARNAME=\"\" -DPACKAGE_VERSION=\"\"
-DPACKAGE_STRING=\"\" -DPACKAGE_BUGREPORT=\"\" -DPACKAGE=\"hello\" -DVERSION=\"1.0\" -I. -I. -I. -O2 -c `test -f 'pubfun.c' || echo './'`pubfun.c
gcc -O2 -o hello hello.o pubfun.o -L. -lm -pthread
备注:
1.以上内容均在RedHat Linux 9.0环境下测试通过。
2.周详的选项可参考由王立翻译的文档http://www.cngnu.org/technology/1657/297.html。
3.其他国内外网站资料
4.RedHat 9.0下带的程式文档及版本
autoconf-2.57-3.noarch.rpm
automake-1.6.3-5.noarch.rpm
gcc-3.2.2-5.i386.rpm
5.附件源文档用如下命令打开即可:
tar xvzf hello-1.0.tar.gz
文章整理:西部数码--专业提供域名注册、虚拟主机服务
http://www.west263.com
以上信息与文章正文是不可分割的一部分,如果您要转载本文章,请保留以上信息,谢谢!




