Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Installation and Deployment
  4. Building Qt from source on Windows
QtWS25 Last Chance

Building Qt from source on Windows

Scheduled Pinned Locked Moved Installation and Deployment
buildsourcewindows 7
8 Posts 3 Posters 7.5k 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.
  • J Offline
    J Offline
    janeb
    wrote on 17 Oct 2015, 23:17 last edited by
    #1

    Linux is my development platform, but I need to package my application for Windows, too. I need to build Qt from source (with -static flag).

    However, I've spent 2+ weeks trying to build Qt on Windows 7, without any success. I followed many tutorials and documents, tried VS, msys2, mingw, options A and B, ... - I lost track of all my attempts. But, each one failed somewhere.

    Has anybody recently built Qt (5.5.0+) from source on Windows 7? If so, which installation instructions should I follow? Happy to start from scratch, slight preference with linux-like tools (rather than VS), but would accept anything. Pretty desperate here.

    1 Reply Last reply
    0
    • L Offline
      L Offline
      Leonardo
      wrote on 18 Oct 2015, 04:04 last edited by
      #2

      Hi. If you feel more comfortable on Linux, why don't you cross compile for Windows? I don't know which distro you have, but there should be a package for mingw-w64, so you can build and deploy from Linux. In theory, after installing the cross compiler, you should just run

      ./configure -xplatform win32-g++ -static ....

      1 Reply Last reply
      0
      • J Offline
        J Offline
        janeb
        wrote on 18 Oct 2015, 08:13 last edited by janeb
        #3

        Hi Leonardo - I tried cross-compiling the application, but that failed too due to some Windows specific optimisation requests. As you said, in theory ...

        Furthermore, the project is very Windows-centric and it does make sense to create a deployment environment on a Windows box.

        1 Reply Last reply
        0
        • J Offline
          J Offline
          JKSH
          Moderators
          wrote on 18 Oct 2015, 12:22 last edited by
          #4

          Hi @janeb ,

          I followed many tutorials and documents... I lost track of all my attempts. But, each one failed somewhere.

          Did you fully clean your source tree between each attempt? Stale files will mess up your build. (Note: Commands like make clean don't work)

          I've only done dynamic builds before, and this is all I need to build:

          > cd C:\path\to\source\root\
          > configure.bat -prefix "C:/path/to/lib/output/" -opensource -confirm-license -nomake examples -nomake tests
          > make
          > make install
          

          (If using MinGW, replace make with mingw32-make. If using MSVC, replace make with nmake)

          AFAIK, all you need to do for a static build is add -static to the configure.bat line (although I've never tried this myself). Does that work? If not, post your first few error messages.

          Also, could you describe why you can't use the pre-built dynamic libraries?

          Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

          1 Reply Last reply
          0
          • J Offline
            J Offline
            janeb
            wrote on 19 Oct 2015, 11:34 last edited by
            #5

            Hi @JKSH - thanks for your comments.

            There were many attempts and I tried to make each one of them from a clean branch of source code. I did use README (where your instructions I presume are from) from the source archive, I tried MinGW Wiki, ... I haven't tried building from Git yet. All attempts failed at some point, so I asked which set of instructions I should follow in order to build Qt5 from source.

            Anyway, yesterday I cleaned the machine completely and started from scratch. This is what I've done so far:

            • installed [Perl] (http://www.activestate.com/activeperl/), ActivePerl-5.22.0.2200-MSWin32-x86-64int-299195.msi
            • installed [Python] (http://www.activestate.com/activepython/), ActivePython-2.7.8.10-win32-x86.msi
            • installed [Ruby] (http://rubyinstaller.org/), rubyinstaller-1.9.3-p550.exe
            • PATH updated, with perl, python and ruby executables
            • installed [Windows SDK 7.1] (https://www.microsoft.com/en-us/download/details.aspx?id=8442), GRMSDKX_EN_DVD.iso

            This morning, I just tried your instructions

            C:\Qt\qt-everywhere-opensource-src-5.5.1>configure.bat -prefix "C:/Qt/5.5.1/" -opensource -confirm-license -nomake examples -nomake tests
            

            and got an error:

            NMAKE : fatal error U1077: 'if' : return code '0x463'
            Stop.
            Could not find output file 'arch.exe' or 'arch' in C:/Qt/qt-everywhere-opensource-src-5.5.1/qtbase/config.tests/arch : No such file or directory
            WARNING: The DirectX SDK could not be detected:
              There is no Direct X SDK installed or the environment variable "DXSDK_DIR" is
            not set.
            Disabling the ANGLE backend.
            
            WARNING: Using OpenGL ES 2.0 without ANGLE.
            Specify -opengl desktop to use Open GL.
            The build will most likely fail.
            (Press any key to continue...)
            
            J 1 Reply Last reply 19 Oct 2015, 12:40
            0
            • J janeb
              19 Oct 2015, 11:34

              Hi @JKSH - thanks for your comments.

              There were many attempts and I tried to make each one of them from a clean branch of source code. I did use README (where your instructions I presume are from) from the source archive, I tried MinGW Wiki, ... I haven't tried building from Git yet. All attempts failed at some point, so I asked which set of instructions I should follow in order to build Qt5 from source.

              Anyway, yesterday I cleaned the machine completely and started from scratch. This is what I've done so far:

              • installed [Perl] (http://www.activestate.com/activeperl/), ActivePerl-5.22.0.2200-MSWin32-x86-64int-299195.msi
              • installed [Python] (http://www.activestate.com/activepython/), ActivePython-2.7.8.10-win32-x86.msi
              • installed [Ruby] (http://rubyinstaller.org/), rubyinstaller-1.9.3-p550.exe
              • PATH updated, with perl, python and ruby executables
              • installed [Windows SDK 7.1] (https://www.microsoft.com/en-us/download/details.aspx?id=8442), GRMSDKX_EN_DVD.iso

              This morning, I just tried your instructions

              C:\Qt\qt-everywhere-opensource-src-5.5.1>configure.bat -prefix "C:/Qt/5.5.1/" -opensource -confirm-license -nomake examples -nomake tests
              

              and got an error:

              NMAKE : fatal error U1077: 'if' : return code '0x463'
              Stop.
              Could not find output file 'arch.exe' or 'arch' in C:/Qt/qt-everywhere-opensource-src-5.5.1/qtbase/config.tests/arch : No such file or directory
              WARNING: The DirectX SDK could not be detected:
                There is no Direct X SDK installed or the environment variable "DXSDK_DIR" is
              not set.
              Disabling the ANGLE backend.
              
              WARNING: Using OpenGL ES 2.0 without ANGLE.
              Specify -opengl desktop to use Open GL.
              The build will most likely fail.
              (Press any key to continue...)
              
              J Offline
              J Offline
              JKSH
              Moderators
              wrote on 19 Oct 2015, 12:40 last edited by JKSH
              #6
              • installed [Ruby] (http://rubyinstaller.org/), rubyinstaller-1.9.3-p550.exe

              This is not needed unless you want to build Qt WebKit, which is now deprecated. (But if you want Qt WebKit, you'll need several other dependencies)

              • installed [Windows SDK 7.1] (https://www.microsoft.com/en-us/download/details.aspx?id=8442), GRMSDKX_EN_DVD.iso

              I'd recommend installing Visual Studio 2013 Express (or Community Edition) instead. Windows SDK 7.1 is very old.

              NMAKE : fatal error U1077: 'if' : return code '0x463'
              Stop.
              Could not find output file 'arch.exe' or 'arch' in C:/Qt/qt-everywhere-opensource-src-5.5.1/qtbase/config.tests/arch : No such file or directory
              

              You might have better luck using a 32-bit compiler.

              If you still get this error after switching to Visual Studio 2013, and you want to use a 64-bit compiler, see https://bugreports.qt.io/browse/QTBUG-47118 for clues,

              WARNING: The DirectX SDK could not be detected:
              There is no Direct X SDK installed or the environment variable "DXSDK_DIR" is
              not set.
              Disabling the ANGLE backend.

              WARNING: Using OpenGL ES 2.0 without ANGLE.
              Specify -opengl desktop to use Open GL.

              What is your graphics card? If yours supports OpenGL, try its suggestion and add -opengl desktop to your configuration options. (If your graphics card doesn't support OpenGL, you'll need to install the DirectX SDK)

              Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

              1 Reply Last reply
              1
              • L Offline
                L Offline
                Leonardo
                wrote on 19 Oct 2015, 13:10 last edited by Leonardo
                #7

                Hi. In that case, here's my receipt:

                In my experience, compiling with OpenGL support using mingw-w64 is a bad idea. Its support for the windows API is good, but not as good as Visual Studio's one. Using VS requires little to no knowledge of it. Just download and install the community version.

                Another point is that apparently the configure script is still based on the old DirectX SDK. I might be wrong, but here's how I got it to work. Download DirectX SDK. No need to install. Just extract the exe's content, let's say, to C:\DXSDK .

                After installing Visual Studio, you'll have a shortcut named "Developer Command Prompt for VS2015" in your start menu. Open it. It's different from a normal prompt, as it has most tools from VS already in the PATH variable. Now, start compiling:

                SET DXSDK_DIR=C:\DXSDK
                configure.bat -platform win32-msvc2015 -static ....

                And that's all.

                1 Reply Last reply
                2
                • J Offline
                  J Offline
                  janeb
                  wrote on 19 Nov 2015, 10:31 last edited by
                  #8

                  Hi @JKSH, @Leonardo,

                  Many thanks for your tips and apologies for delay. I got distracted by another task, but will get back to this one again.

                  Just to report what happened so far. All my attempts on one machine failed. Switching to another computer I managed to to statically build Qt and Qt Creator once (using your receipts), but failed to reproduce that again. I'm putting all this down to my inexperience on Windows platform. However, I have learnt a lot and I'll get back to this problem again.

                  BTW, working with VS is not as scary as it originally looked :-). Once I managed to install it, that is. The installation of VS was a pain as due to my inexperience and some bugs. E.g. installing VS via RDC produces a transparent window - I waiting for hours for something to happen, then tried another version of VS, ...

                  Best,
                  J.

                  1 Reply Last reply
                  1

                  • Login

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