building with qmake on Linux - how to prevent qmake from linking to QtCore and QtGui

Stick it to THE MAN picture Stick it to THE MAN · Feb 19, 2010 · Viewed 11.1k times · Source

I have a shared library (with no QT dependency) [library B] that links to another shared library (with no QT dependence as well) [library A].

I am using Qmake and QT Creator 1.3. The problem is that when I build library B and run ldd on the executable, it is being linked to QtCore and QtGui, both of which are pulling in lots of unrequired files, resulting in an executable that is taking long to load, and has unwanted dependencies.

I have tried just about everything to stop qmake from linking these libraries to library B.

A snippet of my project file for library B is shown below:

TEMPLATE = lib
LIBS += -L../datelib/bin -ldatelib_release

QT -= gui core
LIBS   -= -lQtGui -lQtCore
CONFIG += dll
CONFIG += debug_and_release

CONFIG(debug, debug|release) {
TARGET =targetnameD
}else {
TARGET = targetname
}

I am using QtCreator 3 on Ubuntu 9.10

QT is version 4.5.2

Answer

rohanpm picture rohanpm · Feb 20, 2010

Put CONFIG -= qt in your .pro file.