2

I have created a static library(libPdfWrapper.a) which will use it dependency libraries then i am using libPdfWrapper.a in pdf project but its looking for libPdfWrapper.a dependencies also thought it is static library.

libPdfWrapper.a .pro file which has test1, test2, test3 dependency static libraries

QT       -= gui

TARGET = PdfWrapper
TEMPLATE = lib
CONFIG += staticlib

LIBS += -L$${PWD}/dependencies -ltest1 -ltest2 -ltest3

pdf project .pro file when i include only lPdfWrapper library it is not working it giving link error undefined reference

QT       -= gui

TARGET = Pdf
TEMPLATE = app
LIBS += -L$${PWD}/dependencies -lPdfWrapper

pdf project .pro file with lPdfWrapper library and its dependencies it started working

QT       -= gui

TARGET = Pdf
TEMPLATE = app
LIBS += -L$${PWD}/dependencies -lPdfWrapper -ltest1 -ltest2 -ltest3

Could some one explain me is this necessary? if it why?

Jeggu
  • 569
  • 2
  • 10
  • 26
  • I'm having trouble understanding your problem. What might help is if you could show the directory structure (`tree` output), all `Makefile` content, and the `make` command you invoke. What's expected and how does that differ from what you see? – rubicks Jun 08 '16 at 17:19

1 Answers1

1

When you compile your library as static, it means only YOUR library will be linked statically, so the application won't require a .lib file for YOUR library.

All dynamic libraries which your lib requires, will be still required for the application, which is linked against your static library.

In order to include all dependencies in your library, you should link your library against static versions of test1, test2, test3.

Valentin H
  • 7,240
  • 12
  • 61
  • 111
  • Thanks for reply. Small clarification while building static library it does hold the dependency libraries? I am thinking like my library.a contains test1.a, test2.a test3.a – Jeggu Jun 09 '16 at 02:15