Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt Creator and other tools
  4. QMAKE_POST_LINK runs before linking is complete

QMAKE_POST_LINK runs before linking is complete

Scheduled Pinned Locked Moved Qt Creator and other tools
9 Posts 3 Posters 7.2k 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.
  • A Offline
    A Offline
    Asperamanca
    wrote on last edited by
    #1

    Within the context of a large SUBDIRS project, I have lots of library projects.
    After each library has been built, it needs to be copied to a central libs folder, to be used later by app type projects.

    The only way I found so far that automatically does something after a project has linked is by using the QMAKE_POST_LINK command. I have seen posts using INSTALL, but that requires someone to manually run 'make install', which I don't know how to do within the context of a SUBDIRS project.

    The issue with QMAKE_POST_LINK is that it's command runs before the library is linked. The copy command thus promptly fails, and the build fails. If I remove the QMAKE_POST_LINK, the library links correctly, but of course isn't copied.

    Is there a way I can make QMAKE_POST_LINK work?
    Alternatively, is there a totally different way that will copy my libraries as each sub-project is built?

    1 Reply Last reply
    0
    • sierdzioS Offline
      sierdzioS Offline
      sierdzio
      Moderators
      wrote on last edited by
      #2

      There are several possible ways out of this:

      • "DLLDESTDIR":http://qt-project.org/doc/qt-4.8/qmake-variable-reference.html#dlldestdir
      • "PRE_TARGETDEPS":http://qt-project.org/doc/qt-4.8/qmake-variable-reference.html#pre-targetdeps
      • "SUBDIRS .depends modifier":http://qt-project.org/doc/qt-4.8/qmake-variable-reference.html#subdirs

      (Z(:^

      1 Reply Last reply
      0
      • A Offline
        A Offline
        Asperamanca
        wrote on last edited by
        #3

        Thanks for your input!

        I am already using PRE_TARGETDEPS, but that doesn't change the fact that the libraries are in the wrong folder.

        Same goes for the SUBDIRS .depends modifier.

        Does DLLDESTDIR also work for static libs (.a-files)?

        1 Reply Last reply
        0
        • sierdzioS Offline
          sierdzioS Offline
          sierdzio
          Moderators
          wrote on last edited by
          #4

          I don't know.

          (Z(:^

          1 Reply Last reply
          0
          • A Offline
            A Offline
            Asperamanca
            wrote on last edited by
            #5

            No, it doesn't. :-(

            Solution:
            The command
            @QMAKE_POST_LINK += $$QMAKE_COPY $$quote(../bin/$$(HMK_SUPERMODULE_NAME)/$$(HMK_FULLPLATFORM)/) $$quote(../../public/lib/$$(HMK_SUPERMODULE_NAME)/$$(HMK_FULLPLATFORM)/)@

            seems to work, whereas manually calling the 'cp -r' command doesn't work, even on linux.

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

              Hi,

              If the libraries don't have anything depending on it, why not just set DESTDIR to point to the common folder ?

              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
              • A Offline
                A Offline
                Asperamanca
                wrote on last edited by
                #7

                Because the modules need to compile on their own as well. The modules are compiled and packaged in different ways on different platforms for different purposes. The basic premise is that each module compiles on it's own and creates a static library. Since it cannot depend on any environment, the output must be within the module path.

                Only when multiple modules are combined (e.g. using the master project) does it make sense to copy the output to a central path.

                This is something I cannot change because it's a team-wide decision. I can only add things that won't break things for anyone else.

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

                  I supposed it was something like that but it doesn't hurt to ask :)

                  But then, shouldn't the copy be done a "level upper" so that you don't break the independency of the modules ?

                  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
                  • A Offline
                    A Offline
                    Asperamanca
                    wrote on last edited by
                    #9

                    The permanent solution for the compile server will use scripts for that. However, for test purposes, it's convenient to have a working subdirs project locally, with all the needed projects in it. And I don't know how to tell qmake or Creator to "execute a script right after the last 'lib' has been built, but before any 'app' is being buiilt".

                    EDIT:
                    It only looked like it was solved.
                    It seems that make creates the static library in a different folder, and only moves it to the DESTDIR in a separate step.
                    Whether my copy command or the make's move command comes first seems to be a matter of luck. Therefore, in some cases, my copy command cannot copy the actual static lib, because it's not there yet.

                    EDIT2:

                    The resulting makefile shows this section:
                    @ @$(CHK_DIR_EXISTS) ../bin/_touchpanel/lux_x86-32_gcc463_d/ || $(MKDIR) ../bin/_touchpanel/lux_x86-32_gcc463_d/
                    -$(DEL_FILE) $(TARGET)
                    $(AR) $(TARGET) $(OBJECTS)
                    cp -f /home/hipase-dev/projects/HIPASE/Baseline/sourcen/turm/bin/_touchpanel/lux_x86-32_gcc463_d/libturm_tp.* ../../public/lib/_touchpanel/lux_x86-32_gcc463_d
                    -$(DEL_FILE) ../bin/_touchpanel/lux_x86-32_gcc463_d/$(TARGET)
                    -$(MOVE) $(TARGET) ../bin/_touchpanel/lux_x86-32_gcc463_d/@

                    My 'cp' command is right in the middle, but it should be the last command in this section.

                    1 Reply Last reply
                    0

                    • Login

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