Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change/configure desired compiler in Qt creator? i.e. switch between MSVC/Mingw or g++/clang++

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.

like image 438
Deepak Patel Avatar asked Jun 01 '17 10:06

Deepak Patel


1 Answers

Following is the way with Qt 5.9:

  1. While configuring a new project, select only those compilers/kits which are required;
  2. 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
  3. 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'
  4. In the same dialog box, select the Debuggers tab and similarly add C:/MinGW64/bin/gdb.exe (name it like "MinGW64 Debugger); Click 'Apply'
  5. 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)
  6. 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'
  7. 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
like image 154
iammilind Avatar answered Nov 10 '22 00:11

iammilind