How to get and build the same Qt5 source on both Windows and Mac?



  • I posted what I thought was a simple question to "StackOverflow":http://stackoverflow.com/questions/28594985/how-to-get-qt-5-4-0-source-that-works-for-both-windows-and-os-x but after a week I have no answer, so hopefully someone here can help me?

    I want to get the Qt 5.4.x source once, make a couple minor edits, and build on both Windows and Mac. That was no problem with Qt 4.8.x, but no matter how I obtain the source for Qt 5.4.0, I can't build it on both Windows and Mac. By the way, I have to include qtwebkit in my build.

    If I download the Qt 5.4.0 .zip, I can build on Windows, but configure is missing. If I download the .tar.gz and copy configure into the source from the .zip, qtbase/configure is missing. If I also copy that from the .tar.gz, configure won't run on Mac - it doesn't like the line endings, apparently: configure gives me a "You don't seem to have 'make' or 'gmake' in your PATH" error.

    If I download the .tar.gz file, I can build on Mac, but it's missing configure.bat (and who knows what else), so I can't build on Windows.

    I can get the Qt 5.4.0 source on Mac via git and run perl init-repository. However, when I copy that source to Windows and try to run configure, it complains about missing qtbase\configure.exe. If I copy configure.exe from the .zip version of Qt 5.4.0, configure fails with C:\qt\qt5_git\qtbase\src\corelib\global\qglobal.h(68) : fatal error C1083: Cannot open include file: 'QtCore/qsystemdetection.h': No such file or directory. Of course, the qsystemdetection.h does exist in the same folder as qglobal.h.

    If I use git to get Qt 5.4.0 on Windows and run perl init-repository, that works fine on Windows. But copying that source to OS X yields the same problems as using the .zip file, described above.

    I must be missing something very basic! Surely the source for Qt, the premier cross-platform development framework, can be obtained once and can be copied between Windows and Mac and be built on both? But how?


  • Lifetime Qt Champion

    Hi,

    Indeed the Zip is for Windows and the tar.gz is for *nix operating systems.

    As for the from git source, AFAIK git does the magic of converting the line endings for you unless you tell him no to (avoid doing that unless you're in a particular position like building ffmpeg on Windows)

    AFAIK configure.exe is built for you first thing when you call configure on windows

    Are you calling configure from inside the source tree ? Is it clean before you do ?


  • Moderators

    Hi,

    [quote author="davidb" date="1424880603"]I want to get the Qt 5.4.x source once, make a couple minor edits, and build on both Windows and Mac.[/quote]The most robust way to do this is to create a git patch out of your edits. Check out the git repositories on both platforms, and apply your patch.

    As a bonus, when you download newer versions of Qt in the future, you can simply apply your patch again with one command. No need to edit multiple source files.

    [quote author="davidb" date="1424880603"]If I download the Qt 5.4.0 .zip, I can build on Windows, but configure is missing. If I download the .tar.gz and copy configure into the source from the .zip, qtbase/configure is missing.

    ...

    If I download the .tar.gz file, I can build on Mac, but it's missing configure.bat (and who knows what else), so I can't build on Windows.
    [/quote]The .zip file is bundled for Windows, the .tar.gz file is bundled for OS X/Linux. They have slightly different contents as you've noticed.

    This is mentioned in the "Download page":http://www.qt.io/download-open-source/

    [quote author="davidb" date="1424880603"]I can get the Qt 5.4.0 source on Mac via git and run perl init-repository. However, when I copy that source to Windows and try to run configure, it complains about missing qtbase\configure.exe. If I copy configure.exe from the .zip version of Qt 5.4.0, configure fails[/quote]

    • If you're on OS X/Linux, run configure (the script file with no file extension).
    • If you're on Windows, run configure.bat.

    On all platforms, run configure/configure.bat on the top-level directory, one level up from qtbase. Do not run configure.exe manually.

    [quote author="davidb" date="1424880603"]If I also copy that from the .tar.gz, configure won't run on Mac - it doesn't like the line endings, apparently: configure gives me a "You don't seem to have 'make' or 'gmake' in your PATH" error.

    ...

    If I use git to get Qt 5.4.0 on Windows and run perl init-repository, that works fine on Windows. But copying that source to OS X yields the same problems as using the .zip file, described above.[/quote]If your Mac toolchain doesn't like Windows line endings, then this approach won't work. When you check out a repo, git converts all line endings to match your platform by default. So, checking out code on Windows produces slightly different files than checking out out the same code on Mac.

    I don't know how strict the Windows tools are with line endings though; you could try checking out in Mac and copying to Windows.

    [quote author="davidb" date="1424880603"]Surely the source for Qt, the premier cross-platform development framework, can be obtained once and can be copied between Windows and Mac and be built on both?[/quote]
    The code itself is cross-platform, but the 3rd-party tools involved with building the code have platform-specific requirements.

    Good luck!



  • I don't think it matters which version of the source you use (.zip or .tar.gz). The name of the source file installer is always the same:

    @
    qt-everywhere-opensource-src-5.4.0
    @

    I don't download different versions for my systems (OS X, Linux, Win). I use the same one for each (usually .tar.gz).

    The 'configure.exe' is created as part of the initial configure scripts. In the root and in qtbase you will see a file in each called 'configure.bat' which is what runs when you type 'configure' from the command line. This is only run on windows. You do need Perl which I suspect is how configure.exe is created (?).

    The only issue I have had compiling on windows recently is the line from the root directory configure.bat file

    @
    set "srcpath=%~dp0"
    @

    On my system this doesn't work as intended. I had to manually set the variable path before compiling.



  • On a side note I just realized Qt 5.4.1 was just released two days ago.



  • Thanks all for your replies.

    @SGaist:

    As you say, qtbase\configure.exe seems to be created when running the top-level configure. But the top-level configure doesn't create qtbase\configure.exe if the source has been copied from my Mac. It only works if I get the source (using git or the .zip) directly to Windows.

    Yes, I'm calling configure from inside the source tree, and it is clean. I use git to get the source on Mac, run perl init-repository, then copy the source tree to Windows and try to configure.

    By the way, I don't believe it's an issue with my configuration settings, since I can successfully configure and build with those settings if I use git to get the source directly on Windows.

    @JKSH:
    I've never created a git patch - I'll have to investigate how to do that. Though I'd really prefer to have a single folder of Qt with my edits applied, stored on my server, that I just copy to any machine I need Qt on, whether Windows or Mac.

    I am not trying to run configure.exe directly. I did try to copy it into place before realizing as SGaist and Rondog mentioned that it gets created when configure runs. So part of the problem I'm seeing is that when copying the source from Mac to Windows, configure doesn't create qtbase\configure.exe.

    When I get the source directly on Windows, this works, but if I copy the source from Mac (even if I use git to get it on Mac), it fails as I described:

    configure -prefix



  • Sorry, my post got cut off. Here's the rest of it:

    @configure -prefix



  • ok, it won't let me post my configure call. My question is, are you saying if I copy the code from Mac, I should type "configure.bat ..." instead of "configure ..."?

    @Rondog
    Do you unzip the .tar.gz on Mac, then copy the unzipped folder to Windows? If so, do you do anything special to get it to build on Windows? When I download the .targ.gz, it's missing configure.bat.

    I will check out Qt 5.4.1. Is anyone aware of anything in 5.4.1 that would solve my issue?


  • Moderators

    [quote author="davidb" date="1424887588"]My question is, are you saying if I copy the code from Mac, I should type "configure.bat ..." instead of "configure ..."?[/quote]Yes. Regardless of how you get the source code, you need to run configure.bat.

    configure is a Mac/Linux script and doesn't work on Windows.

    Note that there are 2 different files called configure.bat:

    The top-level configure.bat sets up your environment, and then calls the qtbase configure.bat

    [quote author="davidb" date="1424887588"]When I download the .targ.gz, it's missing configure.bat.[/quote]That's because configure.bat is a Windows-only script, so it was excluded from the .tar.gz (Mac/Linux) package.

    You can grab them from git (see my links above) or from the .zip (Windows) package.

    [quote author="davidb" date="1424887588"]Is anyone aware of anything in 5.4.1 that would solve my issue?[/quote]No, the build process remains unchanged.



  • [quote author="davidb" date="1424887588"]
    ...
    @Rondog
    Do you unzip the .tar.gz on Mac, then copy the unzipped folder to Windows? If so, do you do anything special to get it to build on Windows? When I download the .targ.gz, it's missing configure.bat.

    I will check out Qt 5.4.1. Is anyone aware of anything in 5.4.1 that would solve my issue?
    [/quote]

    Version 5.4.1 won't solve this problem. I just mentioned it because I happened to look (and this thread is about compiling Qt ...)

    I extract the same archive on each platform I intend to compile it on. There are too many files to copy and unless the source is unmodified it is safest to start from the archive. I have software on Windows that can handle various archive formats so it doesn't matter if it is a .zip or .tar.gz in my case.

    I don't do anything special aside from the small edit to the one batch file as mentioned above. I run configure -options ..., make <wait a few hours>, ....

    I always thought the reason for the .zip and .tar.gz is that these are the native archive formats for *nix and windows. By default windows doesn't know how to deal with a .tar.gz archive so it makes sense to provide it as a .zip file (?).

    I did check on my OS X Qt installer folder. I have the two 'configure.bat' files that I know are not needed for OS X or GNU/Linux. I copied the comment above (set "srcpath=%~dp0") from one of the two batch files from this file set.

    If there is a difference between the archive contents (the source archives, not the pre-compiled versions targeting specific configurations) I wasn't aware of it. It might be worth downloading one of each and running a comparison to be sure. I suspect you will find they are the same (I can't say this for sure since I have never done it).



  • @JKSH:

    Are the two configure.bat's the only things missing from the .tar.gz, in order to build on Windows?

    My reason for asking: I'm thinking I could download the Qt 5.4.1 .tar.gz, and copy it to Windows, unzip it there with 7zip, pop in the 2 configure.bat's from the links you mentioned, make my few edits (possibly create a patch file for that), and create a new qt541_with_edits .tar.gz with 7zip.

    Then I should be able to unzip that new .tar.gz on Windows or Mac, and it should build.

    If you see any problems with that plan, I'd appreciate your thoughts!


  • Moderators

    [quote author="davidb" date="1424895453"]Are the two configure.bat's the only things missing from the .tar.gz, in order to build on Windows?[/quote]I'm not sure to be honest, as I've never built with the .tar.gz bundle on Windows. From what Rondog said though, it looks like it.

    [quote author="davidb" date="1424895453"]If you see any problems with that plan, I'd appreciate your thoughts![/quote]None that I can see. :)



  • @JKSH and @Rondog - thanks for your help. Here's what I did that worked:

    1. Download the Qt 5.4.1 .tar.gz on Windows 7.

    2. Unzip with 7zip.

    Both configure.bat's were included! However, qtbase\configure.exe did not get build when configuring. Seems that only happens when I get the source via git.

    1. Download the Q 5.4.1 .zip.

    Turns out, the .zip includes qtbase\configure.exe!

    1. Copy the configure.exe from the .zip and paste it into the source from the .tar.gz.

    2. Make my edits to the .tar.gz source.

    3. Use 7zip to create a new .tar.gz of the source, with my edits.

    I have copied that new .tar.gz to Windows 7 and OS X Yosemite build machines, and it configures and builds on both, including building qtwebkit.

    So I am a happy man! Thanks again for all the help.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.