Important: Please read the Qt Code of Conduct -

Environment setup for multiplatform compilation

  • Hi,

    I'm pretty new to Qt (my previous developments were in C++ / Visual Studio) and would like to know what are the best configuring practices for compiling on multiple platforms?

    A bit of background:
    I currently have an old C++ windows only application that uses a lot of libraries like boost, libpng, libexpat, zlib, libogg etc. The goal is to port this application to the three tablet platforms (iOS, Android & Windows mobile) while also supporting the (windows) desktop users.
    I want to reuse as much as possible code (logic, parsing, custom rendering), my source is in a git repository.

    While investigating how to build the reusable parts of my source i found it to be a pain to compile all those libraries from the web, how do you all do that? is there something similair to nuget for Qt?

    So to say:

    • how can i setup my .qro so that i can compile it on multiple platforms with different targets?
    • how can i prevent struggling building libraries for each target platform?
      is there some form of automation possible that I'm not aware of?
    • considerations, how to place the references in source control (git)?
      also file paths, do you use them relative? as windows can be quite different from iOS I see...

    Is there a way to prevent having to struggle with each library for each target platform and having to maintain only a single qro file?

    Please point me where to start as I'm quite new to those compiling things outside visual studio, I might be missing the points that have become obvious to you...

  • Lifetime Qt Champion

    Hi and welcome to devnet,

    1. What do you mean by "multiple platforms with different targets" ?
    2. Depending on your dependencies, you won't escape building them by hand.
    3. If you want to ensure which files are used where you can use $$PWD to start the path to your files.

    Technically you don't have to leave visual studio if you don't want to. Qt has a plugin for VS that allows you to handle Qt project while working with VS.

  • Hi,

    thanks for the welcome :-)

    What I would like is to stick to developing on windows and deploying to all the different platforms (android, iOS, windows tablet, windows desktop and maybe also OSx and Linux) apparently that seems not possible because its not possible to build for iOS/OSx on a windows machine (correct me if I'm wrong)
    What are the best practices to setup an environment so that I can manage/build for all of the different platforms?

    When I add a library to the .pro file QtCreator also creates conditions for Linux/Windows etc., I was hoping that one of you can point me into what the best practices are or how you do it as for the moment I feel like I'm stumbling between trees in the dark without seeing the forest.

    some libraries use make files others use shell scripts, some just generate a lib/include directory others generate a framework directory with symbolic? links. what is the best to use? how to get it organized so that I can include/reference it in an easy way in my .pro file?

    can someone provide an example how to handle 3rd party library references, in a .pro that can be compiled on windows but also on mac? after you compiled a library do you move all build results (from the different platforms) to git or a network drive?

  • Lifetime Qt Champion

    That first one, you can indeed forget about it, macOS and iOS indeed require a Mac machine.

    If you want to cover all grounds with only one machine then a Mac with e.g. Parallels and virtual machines for Windows and Linux is the most straight forward.

    It really depends on the library you want to use the most common are already available on Linux with dev packages (naming and installation depends on your distribution). On macOS, you can use package managers like macports or homebrew.

    One thing that just came to my mind that will likely be of interest is Note that I haven't used it yet but worth to check.

    3rd party can handled differently: e.g. as sources that you include in your own project, as subproject to build along with your project like for example the 3rdparty dependencies that you can find with Qt.

    Again, for that part might be a good solution.

    For Qt based libraries you can check inqlude or also the qt-pods project.

  • Thanks for the suggestions, I will defenitely take a look at once i got my proof of concept working. it sure looks promising :)

    Is it possible to have subprojects then, i.e. a compiler specific extension .pro file?
    would be nice if that's possible as one would be able to split the platform dependent magic to a different place then
    is that common practice?

  • Lifetime Qt Champion

    Sub-projects are for building different stuff like libraries plugins and your application.

    As for platform and compiler specific stuff, you usually use scopes:

    win32: message(One Line Scope)
    unix:!macx {
        message(More Complex Scope for unix platforms that are not macOS based)
        // more scope specific stuff
    } else {
        message(Scope for mac only stuff)

    If you have common configuration that might be useful for several sub-project then you can use a .pri file that you'd include in your other .pro files. The syntax is exactly the same, the difference of extension just makes it clear that you'll include that file.

Log in to reply