0

I have a .pro file in which I link my libraries using:

LIBS += -L$${OUTDIR} \
        -lA \
        -lB \
        -lC \

I have developed three libraries A, B, C and this is the fourth library I am trying to build, call it D. libD.so needs to link with others. Since I am putting everything under a bin directorty, I added -L$${OUTDIR} there so that it will look for the bin folder for finding libraries. OUTDIR is a variable I set equal to that bin dir and I am sure it is the correct directory. I print it as a message. But I get the error that libD.so can't find libB.so. I am confused here, it finds other A and C, why it can't find B? They are all under the same directory and I am adding that to library path using -L$${OUTDIR}, so. What could be the problem?

By the way, If a delete that -L$${OUTDIR} and instead add that directory directly to LD_LIBRARY_PATH, from QtCreator Projects tab and build configurations, it finds all the libraries correctly.

meguli
  • 1,426
  • 1
  • 18
  • 35

2 Answers2

0

Remove \ after -lC

LIBS += -L$${OUTDIR} \
        -lA \
        -lB \
        -lC
talamaki
  • 5,324
  • 1
  • 27
  • 40
0

It can't find it because at the point in the build where it looks for the library, the library isn't built yet. You need to ensure that the libraries are built in the order of their dependencies.

Kuba hasn't forgotten Monica
  • 95,931
  • 16
  • 151
  • 313
  • But the lib files are built and are there. If I add that directory to `LD_LIBRARY_PATH` manually, everything works fine. Somehow, qmake doesn't generate a makefile that adds `-LOUTDIR` to compiler flags. By the way, same approach works for my other projects. – meguli Apr 07 '17 at 07:58