0

ALL,

I'm trying to figure out a proper link order when I build my software on Linux with gcc.

I have an .a library, which export an interface class (class with a lot of pure virtuals).

This a library is linked to libraryA.so and libraryB.so, because both those libraries have an actual implementation for the interface.

Now libraryB is also linked to unixODBC.

Now, both libraryA and libraryB are linked to libraryC, which actually instantiates the classes from them.

If I understand correctly the linking order should be as follows:

librarya.a libraryA odbc odbcinst libraryB

for libraryC.

But after successful build and running make install, trying to load libraryC fails, because libraryB is not visible.

Is my linking correct? Or better yet - is my understanding of the linking is correct - the referenced library should be first and then follows referencing libraries and I just need to update the LD_LIBRARY_PATH variable.

Thank you for clarifying.

Igor
  • 5,620
  • 11
  • 51
  • 103
  • 1
    Have you had a look [here](https://stackoverflow.com/a/409470/523079)? Unless I've severely misunderstood things, you'll need to do the opposite of what you're doing. – swineone Jul 18 '22 at 02:16
  • @swineone, thank you for the link reference. Fixed and works lie a charm. I upvoted the comment – Igor Jul 18 '22 at 14:05

0 Answers0