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. Best way to build an App proj+Lib proj to build on Windows, Mac, Linux?
QtWS25 Last Chance

Best way to build an App proj+Lib proj to build on Windows, Mac, Linux?

Scheduled Pinned Locked Moved General and Desktop
9 Posts 3 Posters 1.8k Views
  • 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
    CoderTom
    wrote on last edited by
    #1

    I'm new to Qt and Qt creator, but very impressed with what I've seen when researching it lately. I'm struggling trying to figure out how to best accomplish my current goal though with a multiplatform build environment.

    My goal is to setup a Qt app project and a C++ static library project that is used by the app while having it build for Windows, Mac, and Linux. I put both of those projects inside a subdirs project so they are grouped together (I read this is important for the "add library" UI feature). The default for the Qt app and Lib are to have shadow builds enabled. What I'm finding though is this shadow build directory setting if enabled seems to break the feature where you can right click a project and "Add library" for an internal library. When I do that it gives a build error and I see it's looking for the lib in the normal directory and not the shadow build directory.

    If I disable the shadow build directory then it works for my current target platform/configuration, but this doesn't seem like a decent solution. With a multiplatform build environment using source tree shared via a network folder and running qmake on command line from each OS I really kind of need all build output to go into the same folder for each particular build target/configuration.

    I started trying to figure out the variable names I could use inside of my App's .pro file to compute the name of the shadow directory for the lib and patch the default changes Qt Creator did to work with my shadow build folders. I wanted to compute a string like ../build-UtilLib-<TargetPlatform>-$$CONFIG/ , but don't know how to figure out the <TargetPlatform> portion to match the default style Qt Creator uses for shadow build directory paths. At first I thought it was maybe $$QMAKESPEC , but that was a file path. Rather than wasting a lot of time on this I figured I should ask experts since what I was doing may not be nearly as good a solution as others that come recommended.

    Also, one other thing is I really hate the idea of the shadow build directories having to be in the same directory as the project folder was added to. So much clutter is ugly. I went in Qt Creator to change the default so all my shadow build directories are in a top-level Build directory, but as soon as I tried Qt Creator showed a warning saying that's not allowed. It did however still let me leave it that way and appeared to at least partially work since I saw build files go to that new path. Only thing was I still had things broke with the first mentioned issue and I never got a full completed build in that configuration. Any input on how I can accomplish my goal of avoiding clutter and grouping all shadow build type directories in a Build directory?

    Thanks

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

      Hi and welcome to devnet,

      One simple way for that is to control where you put your output files (lib, exec etc.).

      You can use $$OUT_PWD for that. It will contain the path to the folder where the build will be happening.

      Then you can put your libraries in a known folder that you can easily re-use from your other sub-dirs projects. You can also add a .pri file in your "sub-libraries" project that will contain everything needed to build and link to your custom libraries (e.g. include path, LIBS variable setup etc.). That way you also don't need to "pollute" your project with absolute paths.

      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
        CoderTom
        wrote on last edited by
        #3

        Thanks for the reply SGaist. I'll have to look into pri files to learn about them. As for $$OUT_PWD , that will vary for each project right, so I guess you're mentioning that so I can make rules like to copy the generated lib output to a known folder?

        Still I think I'm going to need a $$ type variable that gives me the target type right? Because if I have the same library built for a few platforms, it's going to need to have subdirectories for each platform + like release/config variations. Any idea what variables to look at to get the platform type?

        Also I was curious if their is a way to get a print out of all the variables in a list. Something like you see when you type "set" at a console prompt in windows or "env" at a terminal in Linux.

        1 Reply Last reply
        0
        • joeQJ Offline
          joeQJ Offline
          joeQ
          wrote on last edited by
          #4

          Hi ,new friend, welcome.

          These are my solved question before. maybe they are usefull for you.

          1. rying to understand the .Pro File
          2. How to share custom build step between Win and Osx ?

          Just do it!

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

            Yes, they will change but there are tricks to get the root of the build tree so you can then set your output folders from there. or depending on your project structure simply use something like $$OUT_PWD/../libs for your libraries so you known where to find them when you build your application.

            You usually build your project in different shadow-build folders so no you don't really need that. Take for example how Qt Creator works. One folder per build type per kit used (which represent the targeted platform).

            I'm not aware of a technique to extract all variables from a project.

            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
              CoderTom
              wrote on last edited by
              #6

              joeQ: Thanks, I'll give those links a look over.

              SGaist:

              Ok, Thanks. Still I'm confused about the grouping by target type, even if I use something like a libs/ directory. I'm going to need for instance libs/android-release/<lib files> , libs/linux-x64-release/<lib files>, etc (quite a few types). I wonder if maybe $$QMAKE_TARGET is what I'm looking for to figure out the subdir under libs/.

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

                Are you planning to build your project for each platform in the exact same 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
                • C Offline
                  C Offline
                  CoderTom
                  wrote on last edited by
                  #8

                  From the same source/project directory, but with object and output files to their own platform specific directory.

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

                    So an out of source build for each platform ? Like Qt Creator does ?

                    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

                    • Login

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