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. Sharing projects between sub_dir projects
Forum Updated to NodeBB v4.3 + New Features

Sharing projects between sub_dir projects

Scheduled Pinned Locked Moved General and Desktop
7 Posts 3 Posters 1.7k 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.
  • G Offline
    G Offline
    GoDonkeys
    wrote on last edited by
    #1

    I am building multiple programs that share libraries between them. I have been using a sub_dir project to build one of the programs and need to create a new program that shares some, but not all of the library projects from the first program.

    How would I go about doing that in Qt Creator?

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

      I usually use additional files for .pro projects, like this:
      @
      // .pro
      include(libraryIncludes.pri)

      // libraryIncludes.pri
      LIBS += -lsome/path -LsomeLib
      INCLUDEPATH +=some/include/path
      @

      (Z(:^

      1 Reply Last reply
      1
      • G Offline
        G Offline
        GoDonkeys
        wrote on last edited by
        #3

        Perfect. Thanks!

        Is there anyway to extend this to include the source code so that I can step into it with the debugger and make changes if necessary?

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

          It should work out of the box, I think. The INCLUDEPATH allows you to include library headers in your other (sub)project, and the debugger should be able to see those headers, too.

          (Z(:^

          1 Reply Last reply
          0
          • G Offline
            G Offline
            GoDonkeys
            wrote on last edited by
            #5

            I thought I had it worked out, but it doesn't seem to be working. It's not clear (to me) where each of those files goes.

            If it's not asking too much, could you please let me know how the layout should be if I have the following projects?

            sub_dirs - MainProject
            app - Driver
            staticLib - libA
            staticLib - libB
            staticLib - libC

            The lib* projects already exist and I would like to share them between multiple sub_dirs projects, Driver is a driver program that utilizes libA, libB and libC.

            I've tried several different layouts and either Qt can't find the .pro files or the Driver program can't find the include files for the libraries.

            Thanks for the help.

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

              qmake is very limited when it comes to SUBDIRS: all subprojects you name in the variable need to be placed in a directory with exactly the same name, and in that folder, there needs to be a .pro file - again with the same name. So for your case I would recommend going one dir up and creating a root .pro file there. Like this:
              @
              root.pro (SUBDIRS)
              | sub_dirs
              | app
              | libA
              | libB
              | libC
              @
              Then you can also use the DEPENDS qmake variable to instruct qmake that libraries need to be built before sub_dirs.

              (Z(:^

              1 Reply Last reply
              0
              • N Offline
                N Offline
                notion08
                wrote on last edited by
                #7
                This post is deleted!
                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