Qt 6.11 is out! See what's new in the release
blog
Undefined reference to symbol in static lib
-
There are
lib1.alib1 has class Lib1Class
lib2.alib2.a depends on lib1.a and use Lib1Class
appapp depends of lib2.a and app does not user lib1Class
TARGET = app LIBS += -Llibs_path -llib1 -llib2 INCLUDEPATH += headers_pathSo when I build
appI getundefined reference Lib1Classwhen linking stage.Miracle occurs if I start using
Lib1Classinapp. i.e. in main.cpp create instance of classLib1Class. Everything is linked and works.I tried to use
PRE_TARGETDEPS = $${libs_build_dir}/lib1.aand it does not help.Help me to build
appplease. -
You need to reverse your link order when I'm correct
LIBS += -Llibs_path -llib2 -llib1
See also google for 'c++ link order static', e.g. https://eli.thegreenplace.net/2013/07/09/library-order-in-static-linking