Best way to build an App proj+Lib proj to build on Windows, Mac, Linux?
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?
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_PWDfor 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,
LIBSvariable setup etc.). That way you also don't need to "pollute" your project with absolute paths.
Hope it helps.
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.
Hi ,new friend, welcome.
These are my solved question before. maybe they are usefull for you.
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/../libsfor 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.
joeQ: Thanks, I'll give those links a look over.
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/.
Are you planning to build your project for each platform in the exact same folder ?
From the same source/project directory, but with object and output files to their own platform specific directory.
So an out of source build for each platform ? Like Qt Creator does ?