Using Qt5.5 with MinGW 5.1

  • I've recently started using Qt as a way to make a professional looking GUI for my A level course work, which I've already done quite a lot of with MinGW 5.1. Is there any way I can set up Qt to use MinGW 5.1 (or greater) rather than MSVC 2013, which is the only one of the installed kits which doesn't have something missing? If it helps, I'm using Windows 10 (although I also have Ubuntu, I haven't set it up on there yet).

  • Lifetime Qt Champion

    Hi and welcome to devnet,

    You can use the MinGW package however IIRC, it's currently using 4.9.2. You may have to compile Qt yourself if you want to use 5.1.

    Note that the package also provide MinGW itself.

  • Thank you for the reply. I noticed on the installer that it allows you to install 4.9.1, however I would much rather avoid downgrading my MinGW version. I will attempt to follow this: once I've finished my exams and I'll post again when something goes wrong.

  • Okay, I'm using the link I posted above, and I'm extremely confused by step 3. I rarely use the command line, the only library I've ever build from source is SFML, which is significantly easier. Can someone explain what I should do for step 3 to set it up with MinGW? For the record, I made the file qt5vars.cmd, with these contents:
    REM Set up \MinGW, where <arch> is \c x86
    SET PATH=C:\MinGW\mingw32\bin;%PATH%
    SET _ROOT=C:\Qt\5.5
    SET PATH=%ROOT%\qtbase\bin;%ROOT:\gnuwin32\bin;%PATH%
    SET QMAKESPEC=win32-g++
    SET _ROOT=
    I ran it, a command window opened and closed and then when I use a command prompt to try and run configure, it says that it doesn't understand the command configure.

  • Lifetime Qt Champion

    You are missing the _ before ROOT on your SET PATH line.

    Did you create the desktop link like recommended ?

  • Moderators

    I ran it, a command window opened and closed and then when I use a command prompt to try and run configure

    That's not how .cmd files work. If you just click it it creates a cmd session, runs the commands and closes the session. All changes it made are at this point lost. If you want to use batch files you need to run them from a running session, i.e. call them from cmd.

    Here are basic instructions to compile Qt with MinGW. I'll assume some stuff, adjust to your needs:

    • You did not pollute PATH with any other compiler paths (if you did then you asked for trouble and you got it).
    • Your MinGW installation path is C:\MinGW\mingw32
    • Your Qt sources are in C:\Qt\src
    • You created a build directory: C:\Qt\build
    • You created a final destination directory: C:\Qt\mingw53_x64 //I'm using MinGW 5.3 x64, call the dir whatever you want

    The steps:

    • open command line (cmd.exe)
    • SET PATH = %PATH%;C:\MinGW\mingw32\bin
    • cd C:\Qt\build
    • C:\Qt\src\configure -prefix C:\Qt\mingw53_x64 -debug-and-release -opensource -confirm-license ...
      This will autodetect MinGW environment. No need for any environment variables mangling. Adjust configure call to whatever you need e.g. -nomake examples, -no-icu, -skip webengine etc. Read the docs for configure params available.
    • mingw32-make this will take a while
    • mingw32-make install this copies build artifacts to the prefix directory
    • delete the C:\Qt\build directory with all its contents

  • That's one of the things I didn't understand. Does it just mean to put qt5vars.cmd on the desktop? Or make a shortcut to something else? I'm probably just being dense, but how do you make that desktop link?
    Chris Kawa, I hadn't seen your post when I wrote the above, I'll try following those steps tomorrow, I'm going to bed now. Thank you both for the help. :)

  • After doing what you suggested, it came up with this. It also warned me that I didn't have ANGLE. Do I have to build that myself as well?

  • Moderators

    The instructions I gave were for a build with minimum dependencies i.e. without ANGLE or ICU.

    To build without ANGLE pass -opengl desktop to configure options. To build without ICU pass -no-icu. That's the easiest way to build, but your build will have some restrictions. See Requirements for more info.

    If you want to use ANGLE then DirectX SDK needs to be installed and path to it set via environment variables. It's done differently depending on version of the SDK you use.
    Qt ships with its copy of ANGLE libraries so they are build along with Qt. You can also provide your own build via another environment variable. Refer to the link above again for details.

  • Thank you, it appears to have worked, however I don't know as when I uninstalled Qt, I uninstalled QtCreator with it because I assumed that the source would include QtCreator. I'll have to reinstall that, but once I have, how do I set it up to use the Qt that I've compiled myself?

  • Moderators

    Qt Creator is a separate entity. It's not distributed along with the Qt's sources.
    Follow the documentation to add your compiler and the debugger of your MinGW package. Then add Qt version and set up a kit with all of the above.
    After that you can use that kit as any of the pre-built ones.

  • I've read the links you posted. I've just reinstalled Qt Creator using the standalone installer and when I go to add a Qt version, it can't auto detect any and I can't find any. The bin folder of my install directory, which I make-installed into has only a lot of dlls and a few exes, none of which are qmake. I did a search for qmake in the folder that I installed into and it came up with no results that match my search. For the record, it had auto detected my compiler and debugger already, so I've gone straight to add Qt version.

  • Moderators

    qmake should be directly in the bin directory of your installation folder. If it isn't then something must have gone wrong during the install step.
    Since something actually got compiled (you've got some dlls) I assume qmake was built and it was in the build directory.
    If you removed the build directory already I'm afraid you'll have to build Qt again.

    A long shot but I've heard of some anti-viruses interfere with the install step as it involves copying executables. That's one possible reason why it didn't copy over.
    Can you share your full configure command ?

  • I did delete the build directory after it installed, so I'll do it again, and see if it works that time. I wrote a small batch file so I wouldn't have to keep retyping things:
    @set /p sourcedir= "Enter the source directory "
    @set /p mingwpath= "Enter the mingw installation path "
    @set /p builddir= "Enter the build directory "
    @set /p finaldir= "Enter the final directory "

    cd %builddir%
    call %sourcedir%\configure -prefix %finaldir% -debug-and-release -opensource -confirm-license -nomake examples -no-icu -skip webengine -opengl desktop

    @echo configuration finished

    call mingw32-make

    @echo making finished

    call mingw32-make install

    @echo installing finished

    I removed the bit which added to the path after I'd done that once so that I didn't end up with duplicates in my path.

    EDIT: Okay, it's finished making again, and it's produced exactly the same thing in the install directory (unsurprisingly). There is a qmake.exe in the build directory however, in fact the contents of the two are completely different.
    The install directory has the following folders:
    bin (4 exes and 24 dlls, nothing that has qmake in the name)
    include (one folder per module)
    lib (two folders and a load of prl files and a files)
    mkspec (a modules folder which contains lots of pri files)
    plugins (three folders, each full of dlls)

    The build folder has qtbase, which contains the above as well as a few other folders including a qmake folder. It also has a qmake exe in the bin folder.

Log in to reply

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