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. qmake uses wrong gcc version. How to change gcc version used?
Forum Updated to NodeBB v4.3 + New Features

qmake uses wrong gcc version. How to change gcc version used?

Scheduled Pinned Locked Moved Unsolved General and Desktop
3 Posts 3 Posters 4.0k 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.
  • K Offline
    K Offline
    Kofr
    wrote on last edited by Kofr
    #1

    The compile log is

    cd src/ && ( test -e Makefile || /home/dev/develop/tools/Qt/5.11.2/gcc_64/bin/qmake -o Makefile /home/dev/develop/prj/sq/mobile/src/src.pro -spec linux-g++ CONFIG+=debug CONFIG+=qml_debug ) && /usr/bin/make -f Makefile 
    make[1]: Entering directory '/home/dev/develop/prj/sq/build-ubego-Desktop_Qt_5_11_2_GCC_64bit2-Debug/src'
    /home/dev/develop/tools/Qt/5.11.2/gcc_64/bin/moc -DQT_LOCATION_LIB -DQT_POSITIONINGQUICK_LIB -DQT_QUICK_LIB -DQT_WEBVIEW_LIB -DQT_GUI_LIB -DQT_QML_LIB -DQT_WEBSOCKETS_LIB -DQT_NETWORK_LIB -DQT_POSITIONING_LIB -DQT_SQL_LIB -DQT_CORE_LIB -DQT_QML_DEBUG --include /home/dev/... -I/home/dev/develop/tools/Qt/5.11.2/gcc_64/include -I/home/dev/develop/tools/Qt/5.11.2/gcc_64/include/QtLocation -I/home/dev/develop/tools/Qt/5.11.2/gcc_64/include/QtPositioningQuick -I/home/dev/develop/tools/Qt/5.11.2/gcc_64/include/QtQuick -I/home/dev/develop/tools/Qt/5.11.2/gcc_64/include/QtWebView -I/home/dev/develop/tools/Qt/5.11.2/gcc_64/include/QtGui -I/home/dev/develop/tools/Qt/5.11.2/gcc_64/include/QtQml -I/home/dev/develop/tools/Qt/5.11.2/gcc_64/include/QtWebSockets -I/home/dev/develop/tools/Qt/5.11.2/gcc_64/include/QtNetwork -I/home/dev/develop/tools/Qt/5.11.2/gcc_64/include/QtPositioning -I/home/dev/develop/tools/Qt/5.11.2/gcc_64/include/QtSql -I/home/dev/develop/tools/Qt/5.11.2/gcc_64/include/QtCore -I. -I/usr/include/c++/4.7 -I/usr/include/c++/4.7/backward -I/usr/lib/gcc/x86_64-linux-gnu/4.7/include -I/usr/local/include -I/usr/lib/gcc/x86_64-linux-gnu/4.7/include-fixed -I/usr/include /home/dev/develop/prj/sq/mobile/src/RESTclient/HttpRequestWorker.h -o moc_HttpRequestWorker.cpp
    
    

    You can see that -I/usr/lib/gcc/x86_64-linux-gnu/4.7/include is used
    when there are two version of gcc installed 4.7 and 8.
    How to make it work with gcc-8?

    update-alternatives --display gcc outputs

    gcc - automatic mode
      link best version is /usr/bin/gcc-8
      ссылка сейчас указывает на /usr/bin/gcc-8
      link gcc is /usr/bin/gcc
    /usr/bin/gcc-4.7 — priority 20
    /usr/bin/gcc-8 — priority 800
    
    

    How to make it work with gcc-8?

    1 Reply Last reply
    0
    • VRoninV Offline
      VRoninV Offline
      VRonin
      wrote on last edited by
      #2

      Run the command below before building the program. Not sure if it also works with qmake, it sure does the trick with cmake:

      export CXX="g++-8"
      export CC="gcc-8"
      

      "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
      ~Napoleon Bonaparte

      On a crusade to banish setIndexWidget() from the holy land of Qt

      1 Reply Last reply
      2
      • M Offline
        M Offline
        MhmRhm
        wrote on last edited by MhmRhm
        #3

        Put these in your .pro file.
        QMAKE_CC = gcc-???
        QMAKE_CXX = g++-???
        Where "???" is gcc and g++ version you want to use.
        These links are usefull by the way:

        https://linuxize.com/post/how-to-install-gcc-compiler-on-ubuntu-18-04/
        https://stackoverflow.com/questions/29159520/how-does-qmake-determine-the-compiler-to-use-in-makefile

        By Setting QMAKE_CC and QMAKE_CXX you do not need to use "update-alternatives" command each time that you switch between projects. (you may want one project compile with g++7 and the other with g++8)

        1 Reply Last reply
        0

        • Login

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