Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Is possible to change that qmake uses by default /usr/bin/gcc?
Forum Update on Monday, May 27th 2025

Is possible to change that qmake uses by default /usr/bin/gcc?

Scheduled Pinned Locked Moved Solved General and Desktop
5 Posts 4 Posters 1.6k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    MyNameIsDan
    wrote on 19 Nov 2021, 10:54 last edited by MyNameIsDan
    #1

    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:
    image
    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 :/)

    S J 2 Replies Last reply 19 Nov 2021, 11:07
    0
    • M MyNameIsDan
      19 Nov 2021, 10:54

      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:
      image
      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 :/)

      S Offline
      S Offline
      sierdzio
      Moderators
      wrote on 19 Nov 2021, 11:07 last edited by
      #2

      @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'

      (Z(:^

      M 1 Reply Last reply 19 Nov 2021, 11:39
      3
      • M MyNameIsDan
        19 Nov 2021, 10:54

        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:
        image
        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 :/)

        J Offline
        J Offline
        JonB
        wrote on 19 Nov 2021, 11:07 last edited by
        #3

        @MyNameIsDan
        Does qmake/.pro file allow use of environment variables? If so could you use that to get your personal desired value in there, and the qmake/.pro have a "default" of what other people need to use if the environment variable is not defined, so just you can set it?

        1 Reply Last reply
        0
        • S sierdzio
          19 Nov 2021, 11:07

          @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'
          M Offline
          M Offline
          MyNameIsDan
          wrote on 19 Nov 2021, 11:39 last edited by
          #4

          @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.

          1 Reply Last reply
          0
          • S Offline
            S Offline
            SimonSchroeder
            wrote on 22 Nov 2021, 09:28 last edited by
            #5

            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):

            1. 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.

            1. 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 add CONFIG+=LINUX_GCC11_WORKAROUND into your config.pri to enable them on your machine only.

            1 Reply Last reply
            1

            1/5

            19 Nov 2021, 10:54

            • Login

            • Login or register to search.
            1 out of 5
            • First post
              1/5
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • Users
            • Groups
            • Search
            • Get Qt Extensions
            • Unsolved