I am aware about how to add compiler in Qt Creator. However my Qt always chooses MSVC compiler. How to set MinGW (built-in or external) instead of MSVC?
Couldn't find any post which can help a newbie to know how to change the compiler of desired preference. My current system is Windows, however information on Linux (g++ <--> clang++) is also welcome.
Following is the way with Qt 5.9:
- While configuring a new project, select only those compilers/kits which are required;
- For 64-bit system, get the latest MinGW and install in a suitable path; While installing MinGW64, you may select "posix threads", and not "win32 threads" to allow threading related libraries
- Go to
Tools > Options > Build & Run > Compilers
and add a manual C++ compiler. Choose the path of where you installed C:/MinGW64/bin/g++.exe
(name it something like "MinGW64"); Similarly you may add C compiler as well with C:/MinGW64/bin/gcc.exe
; Click 'Apply'
- In the same dialog box, select the
Debuggers
tab and similarly add C:/MinGW64/bin/gdb.exe
(name it like "MinGW64 Debugger); Click 'Apply'
- In the same dialog box, select the
Qt Versions
and add a new Kit with MinGW64
like name; However I couldn't find an appropriate qmake.exe
for it; Hence, I decided to use the same qmake.exe
, which came with built-in 32 bit MinGW within Qt package (not sure about this as of now)
- In the same dialog box, now select the
Kits
tab and add a new Manual kit
; You may also follow the way the default MinGW32 bit compiler is configured; Configure Compiler
, Debugger
and Qt Version
for this newly named kit; Click 'Ok'
- On the left pan of Qt creator, click on "Projects" tab, and go to "Build & Run" option there; To avoid confusion, you may disable all the kits which are not required; Just keep the relevant kit and click "Build" with either "Debug" or "Release" setting