如何获取配置脚本以查找库 [英] How to get a configure script to look for a library

查看:72
本文介绍了如何获取配置脚本以查找库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试编写configure.ac文件,以使生成的configure脚本搜索包含给定静态库的库目录,例如libsomething.a.我怎样才能做到这一点?目前,我可以通过以下方法检查一个位置:

I'm trying to write a configure.ac file such that the resulting configure script searches for a library directory containing a given static library e.g. libsomething.a. How can I do this? At the moment I have it check just one location with:

AC_CHECK_FILE([/usr/local/lib/libsomething.a],[AC_SUBST(libsomething,"-L/usr/local/lib -lsomething")],[AC_SUBST(libcfitsio,'')])

但是我希望它尝试自动找到它.而且,如果该库不在默认位置之一中,我想进行配置以说未找到该库,并且可以像通常一样使用--use-something = path指定自定义位置.因此,我还需要检查是否提供了--use-something = path.我在创建配置文件方面还很陌生,而且M4文档不是很容易理解,因此不胜感激.

But I want it to try and find it automatically. And if the library isn't in one of the default locations, I'd like configure to say that the library wasn't found and that a custom location can be specified with --use-something=path as is usually done. So I also need to then check if --use-something=path is provided. I'm pretty new at creating configure files, and the M4 documentation isn't very easy to follow, so would appreciate any help.

谢谢!

推荐答案

弄清这一点的最好方法是查看其他执行类似操作的autoconf宏. Autoconf宏是Bourne Shell脚本和M4代码的混合物,因此它们可以从字面上解决任何可计算的问题.

The best way to figure this out is to look at other autoconf macros that do something similar. Autoconf macros are an amalgam of Bourne shell script and M4 code, so they can literally solve any computable problem.

这是指向我为 MySQL ++ 编写的宏的链接,该宏执行以下操作:

Here's a link to a macro I wrote for MySQL++ that does this: mysql++.m4.

这篇关于如何获取配置脚本以查找库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆