Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
363 views
in Technique[技术] by (71.8m points)

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

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.

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.

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.

Thanks, Chenz

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...