Unsolved qmake uses wrong gcc version. How to change gcc version used?
-
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?
-
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"
-
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-makefileBy 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)