building with qmake on Linux - how to prevent qmake from linking to QtCore and QtGui
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 Cre开发者_开发知识库ator 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
Put CONFIG -= qt
in your .pro file.
You can try with
CONFIG += dll
QT -= gui core
LIBS -= -lQtGui -lQtCore
For apps, you do it like this:
TEMPLATE = app
CONFIG = console
More info here: qmake common projects
I had similar problem. What I did was to create new library project with out qtcore and qtgui. Removed all unnecessary files that was created by wizard. Added my files to project folder and modified the *.pro file. It started to work correctly.
It was some problem with QtCreator, it not read correctly .pro file generating .pro.user, witch QtCreator use to build, and wizard generate correct .pro.user file.
I did this with Qt 4.7
Wish this help.
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.
精彩评论