hamaney
hamaney

Reputation: 498

can we pass a shared library that one of our target's dependency needs at run time?

Upvotes: 0

Views: 66

Answers (1)

Employed Russian
Employed Russian

Reputation: 213754

Can C pass down the location of A.so at run time to B when it needs it?

It's not clear what you mean by that.

C is already arranging for A.so to be loaded (by virtue of linking to A.so). What else do you want to "pass down"?

  • Does B.so really need to link against A.so or it is ok if one of the dependents resolves that for it during link time.

It doesn't have to (as you've observed). But not linking B.so against A.so is error-prone, and in general is considered a bad practice.

For example, if C resolves B.so before A.so B would fail.

Again it's unclear what you mean by "resolves B.so before A.so".

When your binary C directly links against A.so and B.so in whatever order, both A.so and B.so are loaded by the dynamic linker before the first instruction of C executes.

The order only matters if A.so and B.so define conflicting symbols. In that case, the first library to define that symbol "wins" (its symbol is used).

Or the order of loading known which is exactly what is displayed in the output of ldd command

Yes, the order of loading is predefined by the way you link everything, and is exactly what ldd command prints.

Upvotes: 1

Related Questions