Problem with linking static internal library in subdir project
-
Hi, I am trying to link an internal static library inside a shared library.
The project is a subdir project.The compiler does not throw errors when I compile the project with MSVC2017, but when I try to compile the shared library with MinGW I get the error
No rule to make target 'D:/Project/Libraries-Desktop_Qt_5_14_1_MinGW_64_bit-Debug/Message/../Base/debug/libBase_D.a', needed by 'Message_D.dll'. Stop.
The main .pro file looks like this:
TEMPLATE = subdirs SUBDIRS += \ Base \ Message Message.depends = Base CONFIG += ordered
The shared library .pro file looks like this:
QT += core widgets gui CONFIG += c++14 TEMPLATE = lib DEFINES += MESSAGE_LIBRARY CONFIG(release,debug|release) { TARGET = Message } CONFIG(debug,debug|release) { TARGET = Message_D } INCLUDEPATH += $$PWD/../Base DEPENDPATH += $$PWD/../Base win32:CONFIG(release, debug|release): LIBS += -L$$OUT_PWD/../Base/release/ -lBase else:win32:CONFIG(debug, debug|release): LIBS += -L$$OUT_PWD/../Base/debug/ -lBase_D win32-g++:CONFIG(release,debug|release): PRE_TARGETDEPS += $$OUT_PWD/../Base/release/libBase.a else:win32-g++:CONFIG(debug,debug|release): PRE_TARGETDEPS += $$OUT_PWD/../Base/debug/libBase_D.a else:win32:!win32-g++:CONFIG(release,debug|release): PRE_TARGETDEPS += $$OUT_PWD/../Base/release/Base.lib else:win32:!win32-g++:CONFIG(debug,debug|release): PRE_TARGETDEPS += $$OUT_PWD/../Base/debug/Base_D.lib
What am i doing wrong?
-
Hi again @sailord,
now I see you are using Qt 5.14; MinGW is no longer using
debug_and_release
then: QTBUG-80792If you are always using shadow builds, you can turn that off for MSVC too, and that will greatly simplify your project files. I've taken this route some years ago and never looked back.
Regards
-
@sailord said in Problem with linking static internal library in subdir project:
First of all, you should remove this line, as you already specified the dependencies:
CONFIG += ordered
See https://blog.rburchell.com/2013/10/every-time-you-configordered-kitten-dies.html for reason.
Second, it seems you only posted Message.pro, can you also post Base.pro?
It might also be helpful to see more of the compiler log.
Regards
-
Hi again @sailord,
now I see you are using Qt 5.14; MinGW is no longer using
debug_and_release
then: QTBUG-80792If you are always using shadow builds, you can turn that off for MSVC too, and that will greatly simplify your project files. I've taken this route some years ago and never looked back.
Regards
-
Hi @sailord,
by giving
CONFIG-=debug_and_release
in the.pro
files of the different libs, or in a common.pri
file.That will remove the extra
debug
andrelease
subdirs (therefore you need to take care of shadow building yourself) and give you the same build layout on Windows, Linux and Mac.Regards