tags:

views:

659

answers:

4

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

+2  A: 

You can try with

CONFIG += dll
QT     -= gui core
LIBS   -= -lQtGui -lQtCore
gregseth
I have marked your answer up, because it atleast gave me the confidence to look more closely at what was actually being built - and I then realised that (unlike my other projects that were set to release configuration by default), this project was set to default - infact there was no other configuration shown by QtCreator even though the (configuration section of the) .pro file syntax is identical to the other projects. Do you know what could be causing this?
Stick it to THE MAN
Look at and/or delete the yourporjectname.pro.user file.
Mihai Limbășan
@Mihai: this was the first thing I did (before posting my question), it made no difference.
Stick it to THE MAN
Ah, sorry. It was a shot in the dark - many people don't realize that the *user files can also influence the resulting build artifacts.
Mihai Limbășan
+1  A: 

As far as I know, Qt creator doesn't take the .pro configurations into consideration if you don't have them set up separately from the IDE.

You should go to the project's settings, clone the debug configuration, rename it release, set the QMake build configuration to release(!) and change other settings as you see fit. Then you can pick which configuration to build from the IDE.

P.S: Try using Qt Creator 1.3.1 as it fixes a lot of bugs and brings interesting new features.

rpg
Hmm, it appears to have been a 1.2.1 bug. After I installed v3, the problem disappeared ... But just so I know for the future, when I want to create my own configuration, could you please outline the steps required in "cloning" an existing configuration to create a new one?
Stick it to THE MAN
Go to Projects > Build Settings > Add > Clone selected. Then select the new configuration (e.g Release) and expand the QMake build step. Set the QMake build configuration to release and you're done.
rpg
A: 

Put CONFIG -= qt in your .pro file.

Intransigent Parsnip
That did not work either :/
Stick it to THE MAN
It works here.This is the method used for the projects in the Qt source tree which don't link against Qt. In general, it works. See `src/winmain/winmain.pro` in the Qt source tree for an example.Can you double-check:(1) you really ran qmake again and rebuilt everything (do a completely clean build after running qmake).(2) None of the libraries you link against are themselves linking against libQtCore or libQtGui (e.g. `datelib_release` must not link against Qt).
Intransigent Parsnip