Nominate our 2022 Qt Champions!

Qt5.6 Cross Compile

  • Hi.

    I wish to use the Qt to develop an application (Windows, Linux, Mac OS support), but I do have two questions.

    1. Does Qt support build the application for 3 platforms in 1 platform, or I have to compile the source code in the corresponding operation system?
      For example, in Windows, can build the windows exe application; but does it support to build the Linux and Max OS application. Or in Linux, does Qt support to build the Windows and Mac OS application.

    2. Does the Qt support build command in the command line(qmake, make??). Any automation build command?

    PS : is there any wonderful graphical lib (open source) to recommend.


  • Lifetime Qt Champion

    On Windows it is possible to build for Linux (never tried). On Linux you can build for Windows using MinGW (never tried as well). But in both cases you should expect limitations and problems. For MacOS you have to use XCode and that is only available on Mac!
    In any case I would recommend to build directly on the platform you're targeting.

    If you want to cross compile then you have to cross compile Qt as well.

    One wonderful graphical lib is Qt :-)

  • @jsulm
    Thanks for your reply.

    In Mac OS, QT5.6 is ready to build the qt project (which i create the project on Windows). And I do have tried for this.
    For windows static release, i've build the windows QT source code, and i can add the kit into QtCreator, and works fine.

    I guess, if download the Linux/Mac OS QT source code, and build the source code, then add the kit into QtCreator, maybe this is possible.


  • Lifetime Qt Champion

    I'm not really sure what you mean.
    Do you still want to cross compile?
    If not then there is no need to build Qt by yourself (except you want static libraries).
    Be careful if you use static Qt libraries: check GPLv3 license.

  • I think your definition of 'cross compile' is to have one application that can run on different platforms (question 1). The answer is no, you need to compile your source code for each OS you intend to run the program on.

    Support for terminal / console is provided by all OS's. If you want to compile your program from a command line then this is not a problem (question 2). What is available is more from your choice of compiler or toolkit as opposed to anything else. Automation is not a problem either (I assume you are thinking along the lines of scripts or batch files).

    'Cross Compile' means that you are running one OS and you are compiling applications that will run on another OS or hardware platform. It is common to do this for things like an IPhone for example.

    Note, it is 'Qt' and not 'QT'. The latter is Apple's Quick Time...

  • Lifetime Qt Champion

    @Rondog No, his definition of "cross compile" is correct: build on one OS for several other OS (for example build on Windows and build for Mac and Linux).

  • @jsulm Sorry, 'cross compile' means that you are compiling for a specific target OS or hardware from some other OS or hardware.

    Regardless Qt does not provide any option to create one program that will run on different OS's . You can write one program that can be compiled (unchanged) to run on a different OS but you cannot compile once and have the end result run on different OS's. In terms of cross platform I believe Qt is one of the best options avaiable.

    In order to have one program capable of running on different OS's there would need to be a lot of cooperation between the different vendors. I wouldn't hold my breath...

  • @Rondog
    Hi sir:
    For the description of "cross compile", I mean is there any possibility to build the Linux/Mac executable application in windows platform, Or build the Windows/Mac executable application in the Linux OS.

    I know and I've built the same source code (NOT changed) in different platform (Windows and Mac), and the executable application is OK to run.

  • Lifetime Qt Champion

    @Rondog "You can write one program that can be compiled (unchanged) to run on a different OS" - that's what @CJ-Sur and I mean.

  • @CJ-Sur In theory you can but I haven't heard of anything that you can setup on Windows that would allow you to generate GNU/Linux / OS X executables. GNU/Linux has tool chains that will generate Windows executables that I have seen and this likely has the most options available.

    If I was doing this I would look into setting up a virtual machine for each target OS you want to run your application on. I have, for example, Windows installed in a VM on my GNU/Linux and Apple computers. When I want to produce something for Windows I compile and test inside the VM. If you generate a GNU/Linux application in Windows outside of a VM you then have to find a computer running GNU/Linux to test it on. A VM solves many problems.

  • @Rondog
    OK. Got you.
    I'am investigating is this possible.
    I think I have to use the corresponding desktop or the VM.

Log in to reply