在C/C ++项目中自动检测库依赖关系的最佳方法是什么? [英] What is the best way to auto detect library dependencies in a C/C++ project?

查看:69
本文介绍了在C/C ++项目中自动检测库依赖关系的最佳方法是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在C/C ++项目中自动检测库依赖关系的最佳方法是什么?

What is the best way to auto detect library dependencies in a C/C++ project?

我有一个项目,其中有对计算机的所有依赖项.它生成并运行.现在,我想组装一个自动工具构建系统.我正在寻找一种自动检测所需的所有依赖项(例如,使用的头文件和链接所需的库)的好方法.

I have a project where I have all the dependencies on the machine. It builds and runs. Now I want to put together a autotools build system. I am looking for a good way to auto detect all the dependencies needed such as header files used and libraries needed for linking.

对于我而言,似乎最难识别库位.我想说的是,为列表或其他内容中的每个函数生成AC_CHECK_LIB命令.我可能可以在Perl中做到这一点,但我必须想象它已经存在于其他地方.

The library bit seems to be the hardest for me to figure out. I'd like to be able to say, generate AC_CHECK_LIB commands for every function in a list or something. I could probably do this in Perl, but I've got to imagine it already exists elsewhere.

我所知道的是,我可以使用objdump和nm查看符号,可以找到这些实用程序所属的函数库,然后可以在configure.ac中手动输入AC_CHECK_LIB命令进行检查.在这一点上,自动化将是很棒的.

What I know is that I can view symbols with objdump and nm, I can find what library a function belongs to with these utilties, then I can manually enter an AC_CHECK_LIB command in my configure.ac to check for it. Automation would be awesome at this point.

谢谢, 钦茨

推荐答案

这种详尽的测试(即每个功能)都是不必要的.更不用说它将很难维护并且需要一段时间才能运行.

That sort of exhaustive testing (i.e., every function) is unnecessary. Not to mention that it would be hard to maintain and take a while to run.

测试您知道需要进行测试的功能.如果您只是在测试是否存在库,请选择要在测试中使用的常用函数.如果要确保仅在较新版本中可以使用某些功能,请使用仅在较新版本中找到的功能进行测试.

Test for features that you know warrant a test. If you're just testing for the existence of a library, pick a commonly used function to use in your test. If you want to make sure some feature only in newer vesions is available, test using a function only found in those newer versions.

这篇关于在C/C ++项目中自动检测库依赖关系的最佳方法是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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