1

I have this situation:

  • libA.a that has no dependencies
  • libB.a that depends on libA.a
  • libC.a that depends on libA.a

in B.pro i have

LIBS += -lA

in C.pro i have

LIBS += -lA

in app.pro i have

LIBS += -lA
LIBS += -lB
LIBS += -lC

But when i compile the linker gives me undefined references on libA classes that are used in libB and libC.

How can i fix this? Thank you

drescherjm
  • 10,365
  • 5
  • 44
  • 64
Fausto01
  • 171
  • 14

1 Answers1

2

LIBS += -lA are ignored in B.pro and C.pro. That option is applicable only for the linker, i.e. then a shared library or executable binary are built.

To resolve the issue with the undefined references reorder libs in app.pro. The order of dependent libraries does matter. See The order in which interdependent linked libraries are specified is wrong.

LIBS += -lB
LIBS += -lC
LIBS += -lA
273K
  • 29,503
  • 10
  • 41
  • 64