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. Using libraries with multiple kits
Forum Updated to NodeBB v4.3 + New Features

Using libraries with multiple kits

Scheduled Pinned Locked Moved Unsolved General and Desktop
6 Posts 2 Posters 1.6k 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.
  • C Offline
    C Offline
    Colin Ward
    wrote on last edited by
    #1

    Hello.

    I have a project that uses a static library, made by me. I include the library from my project's .pro file thus:

    build_pass:CONFIG(debug, debug|release) {
    LIBS += -L../StdFuncs/DebugQt
    }

    build_pass:CONFIG(release, debug|release) {
    LIBS += -L../StdFuncs/ReleaseQt
    }

    LIBS += -lStdFuncs

    You can see that there are debug and release versions of the library that are built into different directories. When I build this from the command line it works fine, under both Linux and Windows. If I import it into Qt Creator, and I disable the "shadow build" in project settings then it also works.

    However then I cannot switch between compilers (I like to compile with MSVC 32 and 64 bit, plus GCC to catch all warnings) because everything is built into the same directory. So I turn on shadow build and now everything is built into separate directories such as "build-StdFuncs-Desktop_Qt_5_7_0_MSVC2013_32bit-Debug/DebugQt" so of course now the libraries are not found.

    When I followed the instructions for adding an external static library using Qt Creator, it works, but ends up with these ugly hard coded paths in my .pro file:

    win32: LIBS += -L$$PWD/../build-StdFuncs-Desktop_Qt_5_7_0_MSVC2013_32bit-Debug/DebugQt/ -lStdFuncs

    Ugh. Not only is it ugly but it means that If I want to compile with both MSVC 2013 and MSVC 2015 for 32 bit or for 64 bit then I end up with all of these ugly hard coded paths in my .pro file which clash with one another.

    So I figured there has to be a better way, such as a magic variable such as $$KIT_OUT that is changed when the .pro file is parsed to be changed to the name of the kit you are using. But I cannot find this anywhere. Actually I fought for this for ages until I found the "shadow copy" checkbox.

    Is there a way to do something like this? qmake is so well done I can't believe that such an ugly architectural problem would have been missed by its designers.

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi and welcome to devnet,

      You can use the OUT_PWD variable to setup your path i.e. LIBS += -L$$OUT_PWD/StdFuncs/DebugQt and you should be good to go.

      Hope it helps.

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • C Offline
        C Offline
        Colin Ward
        wrote on last edited by Colin Ward
        #3

        Hello mate.

        Unfortunately OUT_PWD is the output directory of the current project. So in the case where I am linking an executable with a library it is the directory of the executable. But what I want is the output directory of the dependent library. I have searched all through the documentation and tried everything but it seems that this is not supported.

        I am going to raise a bug. Unless this functionality is well hidden, it is missing.

        Thanks for the suggestion anyway.

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          Sorry, I thought you were using the subdirs template for your project. It's not the case, is it ?

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          C 1 Reply Last reply
          0
          • SGaistS SGaist

            Sorry, I thought you were using the subdirs template for your project. It's not the case, is it ?

            C Offline
            C Offline
            Colin Ward
            wrote on last edited by
            #5

            @SGaist said in Using libraries with multiple kits:

            Sorry, I thought you were using the subdirs template for your project. It's not the case, is it ?

            No, I am using the two projects side by side on the same level. I investigated the subdirs template but to use that I would need to have a specially checked out version of my project that used a different layout. Anyway I got it working by turning off the shadow directory, although this seems quite a missing piece of functionality to me, so I also raised an issue in Jira. In here someone has given the same answer as you have and then closed the issue, so it seems that this use case simply isn't considered. :-/ Oh well.

            1 Reply Last reply
            1
            • SGaistS Offline
              SGaistS Offline
              SGaist
              Lifetime Qt Champion
              wrote on last edited by
              #6

              Your use case matches rather this setup: external dependency that you build and install in a known place like for example /usr/local on *nix system.

              Interested in AI ? www.idiap.ch
              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

              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