Hiding inter-library dependencies.

"Daniel." <[email protected]> Tue, 16 Aug 2016 11:14:16 -0300
Newsgroups gmane.linux.c-programming
Message-ID <CAF3SDA7nNWNCrfY3MT8PfU6kU7E8JjLnPXcohJL896_o3hGWcQ@mail.gmail.com>
Hi everybody!

Suppose that I have 3 shared files,
and two target machines M1 and M2.

libA.so, libB.so and libC.so.

libB.so is linked against libA.so only when compiled
to M1, but not in M2.

libC.so is aways linked against libB.so

So we have:

M1: libA.so <- libB.so <- libC.so <- executable.
M2:                   libB.so <- libC.so <-executable

I want to hide libA.so need while linking libB,
so that libC has not to pass -lA to linker depending
on machine. And to
hide libB and libA while linking to libC, so that
the user need to pass only -lC. Is that possible?

For example, linking in M1 would be:
cc -fPIC -shared -o libA.so libA.c
cc -fPIC -shared -o libB.so libB.c -lA
cc -fPIC -shared -o libC.so libC.c -lB (no need to -lA is the point here)
cc -o executable executable.c -lC (no need to -lB -lA is the point here)

And for M2 would be:
cc -fPIC -shared -o libB.so libB.c
cc -fPIC -shared -o libC.so -lB
cc -o executable executable.c -lC

In both cases (machines) the compilation of executable and libC
is done by the same command line.


Cheers,


-- 
"Do or do not. There is no try"
  Yoda Master
--
To unsubscribe from this list: send the line "unsubscribe linux-c-programming" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html