2

I wrote a static library called libverify_passwd.a using llvm-ar-7, which use symbol getpwuid, getspnam and crypt. It requires special linker argument -lcrypt and -lc (if -nostdlib is specified).

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. 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?

JiaHao Xu
  • 2,452
  • 16
  • 31
  • You may benefit from using CMake to generate your make files. But generally, asking for tool recommendations is off-topic. – StoryTeller - Unslander Monica Jan 08 '19 at 09:19
  • Static libraries are not created by the linker. Since no linkage happens in the creation of a static library, you cannot link anything to a static library. Read [the Stackoverflow tag wiki about static-libraries](https://stackoverflow.com/tags/static-libraries/info) – Mike Kinghan Jan 08 '19 at 09:22
  • 1
    Add the list of required libraries to the documentation of your library. You may add examples of the linker command line. – Paul Ogilvie Jan 08 '19 at 09:52

1 Answers1

2

Look at How to merge two “ar” static libraries into one? to make a new lib containing what you want

However the best way is to continue to use -lcrypt at link time

bruno
  • 32,421
  • 7
  • 25
  • 37