Is possible to change that qmake uses by default /usr/bin/gcc?
-
wrote on 19 Nov 2021, 10:54 last edited by MyNameIsDan
I have added my new compiler with the path gcc-11 & g++-11, and actually create a new kit that uses by default that compiler:
but when i recompile my projects i get::-1: warning: "/usr/bin/g++" is used by qmake, but "/usr/bin/g++-11" is configured in the kit. Please update your kit (New kit with new compiler) or choose a mkspec for qmake that matches your target environment better.
so i read that the solution is to add to the project file:
QMAKE_CC = gcc-11 QMAKE_CXX = g++-11
BUT I can't do that. I will be working on a project with other users through git, and all of our projects are going to be developed in linux in gcc 11.2, and we want to compile for windows & mac (with any compiler) actually so i cannot modify the project file in that way.
So, If possible i would like to create a kit that actually uses my gcc-11, if not possible, I would prefer to configure my qt to always use gcc-11 by default (otherwise i guess I will change my /usr/bin/gcc archive :/) -
I have added my new compiler with the path gcc-11 & g++-11, and actually create a new kit that uses by default that compiler:
but when i recompile my projects i get::-1: warning: "/usr/bin/g++" is used by qmake, but "/usr/bin/g++-11" is configured in the kit. Please update your kit (New kit with new compiler) or choose a mkspec for qmake that matches your target environment better.
so i read that the solution is to add to the project file:
QMAKE_CC = gcc-11 QMAKE_CXX = g++-11
BUT I can't do that. I will be working on a project with other users through git, and all of our projects are going to be developed in linux in gcc 11.2, and we want to compile for windows & mac (with any compiler) actually so i cannot modify the project file in that way.
So, If possible i would like to create a kit that actually uses my gcc-11, if not possible, I would prefer to configure my qt to always use gcc-11 by default (otherwise i guess I will change my /usr/bin/gcc archive :/)@MyNameIsDan said in Is possible to change that qmake uses by default /usr/bin/gcc?:
and we want to compile for windows & mac (with any compiler) actually so i cannot modify the project file in that way.
But you can scope it down to linux only:
linux { QMAKE_CC = gcc-11 QMAKE_CXX = g++-11 }
Anyway, looks like the solutions for you are:
- modify mkspec
qt-installation-path/mkspecs/common/g++-base.conf
and change all the paths and flags as you like. If you don't want to modify existing mkspecs, you can make your own and then call qmake with-spec path/to/your/specs
- or replace
/usr/bin/g++
with a symlink to `/usr/bin/g++-11'
- modify mkspec
-
I have added my new compiler with the path gcc-11 & g++-11, and actually create a new kit that uses by default that compiler:
but when i recompile my projects i get::-1: warning: "/usr/bin/g++" is used by qmake, but "/usr/bin/g++-11" is configured in the kit. Please update your kit (New kit with new compiler) or choose a mkspec for qmake that matches your target environment better.
so i read that the solution is to add to the project file:
QMAKE_CC = gcc-11 QMAKE_CXX = g++-11
BUT I can't do that. I will be working on a project with other users through git, and all of our projects are going to be developed in linux in gcc 11.2, and we want to compile for windows & mac (with any compiler) actually so i cannot modify the project file in that way.
So, If possible i would like to create a kit that actually uses my gcc-11, if not possible, I would prefer to configure my qt to always use gcc-11 by default (otherwise i guess I will change my /usr/bin/gcc archive :/)wrote on 19 Nov 2021, 11:07 last edited by@MyNameIsDan
Doesqmake
/.pro
file allow use of environment variables? If so could you use that to get your personal desired value in there, and theqmake
/.pro
have a "default" of what other people need to use if the environment variable is not defined, so just you can set it? -
@MyNameIsDan said in Is possible to change that qmake uses by default /usr/bin/gcc?:
and we want to compile for windows & mac (with any compiler) actually so i cannot modify the project file in that way.
But you can scope it down to linux only:
linux { QMAKE_CC = gcc-11 QMAKE_CXX = g++-11 }
Anyway, looks like the solutions for you are:
- modify mkspec
qt-installation-path/mkspecs/common/g++-base.conf
and change all the paths and flags as you like. If you don't want to modify existing mkspecs, you can make your own and then call qmake with-spec path/to/your/specs
- or replace
/usr/bin/g++
with a symlink to `/usr/bin/g++-11'
wrote on 19 Nov 2021, 11:39 last edited by@sierdzio actually the first one is a good one, if the project is developed in linux and we accept the fact that is going do be in other compiler for the final release for other platforms, that is viable.
But right now I prefer to modify my mkspecs. - modify mkspec
-
wrote on 22 Nov 2021, 09:28 last edited by
There are two ways I see to make you opt in to these settings explicitly, so that it is specific to your machine (another Linux machine might be configured differently):
- Use an additional config variable which you specify when compiling on your machine. Inside the .pro file:
LINUX_GCC11_WORKAROUND { QMAKE_CC = gcc-11 QMAKE_CXX = g++-11 }
Inside QtCreator in the projects settings for the qmake step specify
CONFIG+=LINUX_GCC11_WORKAROUND
as additional argument. On the command line just add it to your options:qmake CONFIG+=LINUX_GCC11_WORKAROUND [...] MyProject.pro
This is quite similar to @sierdzio's suggestion. But it is more explicit if other Linux machines are configured differently.- My preferred method for this is a user-specific
config.pri
. This is what we have in our .pro files:
exists(config.pri): include(config.pri)
Every user can specify whatever they like inside the
config.pri
. This file will not be checked in to version control so that everyone can keep their own settings. Nobody ever has to know about your machine specific settings. If there are a dozen workarounds for different machines your .pro file will not be cluttered up by all the different workarounds like in version 1. I described.The two approaches can also be combined: If you want to keep track of all workarounds (maybe put them in a
workarounds.pri
checked into the version control) you can addCONFIG+=LINUX_GCC11_WORKAROUND
into yourconfig.pri
to enable them on your machine only.
1/5