Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Problem with linking static internal library in subdir project
Forum Updated to NodeBB v4.3 + New Features

Problem with linking static internal library in subdir project

Scheduled Pinned Locked Moved Solved General and Desktop
5 Posts 2 Posters 439 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    sailord
    wrote on last edited by
    #1

    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?

    aha_1980A 2 Replies Last reply
    0
    • S sailord

      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?

      aha_1980A Offline
      aha_1980A Offline
      aha_1980
      Lifetime Qt Champion
      wrote on last edited by
      #3

      Hi again @sailord,

      now I see you are using Qt 5.14; MinGW is no longer using debug_and_release then: QTBUG-80792

      If 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

      Qt has to stay free or it will die.

      1 Reply Last reply
      3
      • S sailord

        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?

        aha_1980A Offline
        aha_1980A Offline
        aha_1980
        Lifetime Qt Champion
        wrote on last edited by
        #2

        @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

        Qt has to stay free or it will die.

        1 Reply Last reply
        3
        • S sailord

          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?

          aha_1980A Offline
          aha_1980A Offline
          aha_1980
          Lifetime Qt Champion
          wrote on last edited by
          #3

          Hi again @sailord,

          now I see you are using Qt 5.14; MinGW is no longer using debug_and_release then: QTBUG-80792

          If 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

          Qt has to stay free or it will die.

          1 Reply Last reply
          3
          • S Offline
            S Offline
            sailord
            wrote on last edited by
            #4

            Thanks for the help.
            @aha_1980 how do I turn it off for MSVC?

            aha_1980A 1 Reply Last reply
            0
            • S sailord

              Thanks for the help.
              @aha_1980 how do I turn it off for MSVC?

              aha_1980A Offline
              aha_1980A Offline
              aha_1980
              Lifetime Qt Champion
              wrote on last edited by
              #5

              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 and release subdirs (therefore you need to take care of shadow building yourself) and give you the same build layout on Windows, Linux and Mac.

              Regards

              Qt has to stay free or it will die.

              1 Reply Last reply
              1

              • Login

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • Users
              • Groups
              • Search
              • Get Qt Extensions
              • Unsolved