[英]How to make linking to a static library also link to its dependency as well?
I wrote a static library called libverify_passwd.a
using llvm-ar-7
, which use symbol getpwuid
, getspnam
and crypt
.我使用llvm-ar-7
编写了一个名为libverify_passwd.a
的静态库,它使用符号getpwuid
、 getspnam
和crypt
。 It requires special linker argument -lcrypt
and -lc
(if -nostdlib
is specified).它需要特殊的链接器参数-lcrypt
和-lc
(如果指定了-nostdlib
)。
Another project of mine depend on this static library and it will be cumbersome and hard to maintain by adding -lcrypt
to the Makefile
of that project.我的另一个项目依赖于这个静态库,将-lcrypt
添加到该项目的Makefile
中会很麻烦且难以维护。 Is there any way so that during the link time, the dependency can be solved automatically, or is there any other tool that simplify the maintenance of this?有什么办法可以在链接期间自动解决依赖关系,或者有没有其他工具可以简化维护?
Look at How to merge two “ar” static libraries into one?看看如何将两个“ar”静态库合并为一个? to make a new lib containing what you want制作一个包含你想要的东西的新库
However the best way is to continue to use -lcrypt
at link time但是最好的方法是在链接时继续使用-lcrypt
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.