qtqmakeqt6

Why is qmake6 generating graphics related includes for QCoreApplication?


I'm using QT 6.6.1 qmake 3.1 with the following project config:

QT   += core network  
LIBS += -lssl -lcrypto -lsystemd  

However qmake6 generates:

INCPATH       = -I. -I/usr/include/qt6 -I/usr/include/qt6/QtGui -I/usr/include/qt6/QtNetwork -I/usr/include/qt6/QtCore -Ibin -I/usr/lib/qt6/mkspecs/linux-g++  
LIBS          = $(SUBLIBS) -lssl -lcrypto -lsystemd /usr/lib/libQt6Gui.so /usr/lib/libGLX.so /usr/lib/libOpenGL.so /usr/lib/libQt6Network.so /usr/lib/libQt6Core.so -lpthread -lGLX -lOpenGL  

I was able to compile without the graphics related headers and libraries. Is there a reason why qmake generates these by default?


Solution

  • The solution to remove the graphics related includes and libraries is to add:

    QT -= gui
    

    This is because the QtGui was enabled by default for a while. Source: https://forum.qt.io/post/259728
    However, this will have no effect on binary size or the output of ldd on linux. Gcc already knows the libraries are not needed.