c++ - Is specifying link dependency required when one static lib is dependent on another static lib? -
this question has answer here:
general question can formulated - if static library lib1 dependent on static library lib2, need specify lib2 linker dependency lib1, or linking dependencies need specified when libraries linked against application (and every application using lib2 should link against lib1 well)?
specifically, have bunch of static libs , applications, dependencies between them, that:
makeall.pro:
template = subdirs config += ordered subdirs = corelib \ anotherlib \ .... someapp anotherlib.depends = corelib someapp.depends = corelib anotherlib
corelib.pro
template = lib config += staticlib target = corelib #... .cpp , .h
anotherlib.pro
template = lib config += staticlib includepath += path_to_core_lib_includes dependpath += path_to_core_lib_includes target = anotherlib
#lines in question
someapp.pro
template = app destdir = ..\bin includepath += path_to_core_lib_includes path_to_another_lib_includes dependpath += path_to_core_lib_includes path_to_another_lib_includes
#lines in question
what should use lines in question:
anotherlib.pro
(nothing required)
someapp.pro
pre_targetdeps += ../bin/corelib.lib ../bin/anotherlib.lib
or:
ii. anotherlib.pro
pre_targetdeps += ../bin/corelib.lib
someapp
pre_targetdeps += ../bin/anotherlib.lib
or
iii. anotherlib.pro
pre_targetdeps += ../bin/corelib.lib
someapp.pro
pre_targetdeps += ../bin/corelib.lib ../bin/anotherlib.lib
when building static library not need link in other static libraries.
when building executable, need include libraries code , libraries code depends on. libraries need in right order. if lib foo depends on lib c, must use -lfoo -lc.
in distant past order of object files within static library important, no more.
Comments
Post a Comment