Makefile automatic link dependency ?

Posted by Kuang Chen on Stack Overflow See other posts from Stack Overflow or by Kuang Chen
Published on 2010-03-19T04:25:41Z Indexed on 2010/03/19 4:31 UTC
Read the original article Hit count: 192

Filed under:
|
|
|

It's easy to let program figure out the dependency at compile time, (with gcc -MM). Nevertheless, link dependency (deciding which libraries should be linked to) seems to be difficult to figure out. This issue become emergent when multiple targets with individual libraries to link to are needed.

For instance, three dynamic library targets t1.so, t2.so and t3.so needs to be built. t1.so needs math library (-lm), while t2 and t3 don't. It would be tedious to write separate rules. A single rule requiring the three targets linked with math library saves the trouble. However, it causes inflation of target size since math library is unused for t2.so and t3.so.

Any ideas?

© Stack Overflow or respective owner

Related posts about makefile

Related posts about dependency