Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

qt

qmake

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

like image 354
Stick it to THE MAN Avatar asked Feb 19 '10 13:02

Stick it to THE MAN


People also ask

What is the use of pro file in Qt?

The purpose of a . pro file is to list the source files that are involved in a project. Since qmake is used for building Qt and its associated tools, it knows Qt very well and can generate rules for invoking moc, uic, and rcc. As a result, the syntax is very concise and easy to learn.

What does run qmake do?

The behavior of qmake can be customized when it is run by specifying various options on the command line. These allow the build process to be fine-tuned, provide useful diagnostic information, and can be used to specify the target platform for your project.

Where is qmake in Qt?

qmake.exe is in bin directory of your Qt installation folder (along with all the Qt dlls for deployment). Your compiler should be detected automatically (check the Tools > Options > Build & Run > Compilers tab).


2 Answers

Put CONFIG -= qt in your .pro file.

like image 112
rohanpm Avatar answered Sep 21 '22 23:09

rohanpm


You can try with

CONFIG += dll
QT     -= gui core
LIBS   -= -lQtGui -lQtCore
like image 34
gregseth Avatar answered Sep 22 '22 23:09

gregseth