How to handle lib dependency while compiling?

79 views Asked by At

Let's say that I have two static libraries : libA and libB and that libB uses libA.

For each library libX let's say that hX is libX's headers's directory and dX is libX's file's directory.

Now what happen when a user of libB wants to compile a source code C.c using libB ? Must he be aware that libB uses libA and so he must type :

gcc -IhB -IhA C.c -lA -LdA -lB -LdB

Or is there a way to make libB automatically 'says' to gcc to use libA so a user could type :

gcc -IhB -IhA C.c -LdA -lB -LdB

?

1

There are 1 answers

0
Kaz On

Yes, all static libraries which are required must be listed on the command line. These are just special archive files that provide .o files. Just like you cannot omit required .o files, you cannot omit required archives.