I installed Qt-5.15.0 (macos community binary), and started to use it for C++ development. I have gcc-10.2.0 installed through brew, and available at /usr/local/bin/gcc, which is a symbolic link to /usr/local/Cellar/gcc/10.2.0/bin/g++-10
By default, qtcreator uses apple's clang compiler, so I followed the answer 18847536 and set QMAKE_CXX = g++ in hello.pro file. But that gave me the following error:
"/usr/bin/g++" is used by qmake, but "/usr/bin/clang++" is configured in the kit.
Please update your kit (Desktop Qt 5.15.0 clang 64bit) or choose a mkspec for qmake
that matches your target environment better.
I see a couple of problems here - instead of /usr/local/bin/g++, the /usr/bin/g++ has been selected. And there is a conflict with the kit's compiler.
For the path problem, I followed the answer in 56759069, and changed hello.pro to specify full path of g++, and to set the gcc's c++11 option like this in hello.pro file:
QMAKE_CXX = /usr/local/bin/g++
#CONFIG += c++11 console # this was for clang
CONFIG += c++0x console # this is for gcc
Now I get this error:
"/usr/local/bin/g++" is used by qmake, but "/usr/bin/clang++" is configured in the kit.
Please update your kit (Desktop Qt 5.15.0 clang 64bit) or choose a mkspec for qmake
that matches your target environment better.
So now, how do I tell the kit to use the same version of gcc, or to make a new kit that uses this gcc?
I tried visiting Tools > External > Configure > Kits, and adding a new kit there or to change the kit configurations. But I could not find a way to specify my gcc version there.
Before creating a new Kit, you want to create new compiler entries. Look into Preferences => Kits => Compilers, and press "Add". Select GCC, and specify the path to it. Afterwards select g++ and do the same. Once you have done that, select the new compilers in your new Kit.
In theory just pressing "Re-detect" on the compilers page should also find g++ and gcc automatically.