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

你。 提交于 2019-12-10 16:53:39

问题


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.


回答1:


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


来源:https://stackoverflow.com/questions/44305485/how-to-change-configure-desired-compiler-in-qt-creator-i-e-switch-between-msvc

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!