English 中文(简体)
building with qmake on Linux - how to prevent qmake from linking to QtCore and QtGui
原标题:
  • 时间:2010-02-19 13:21:57
  •  标签:
  • 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

问题回答

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.





相关问题
Qt: Do events get processed in order?

If I had a class A, where one of its functions does: void A::func() { emit first_signal(); emit second_signal(); } Assuming that a class B has 2 slots, one connected to first_signal, and the ...

How to determine how much free space on a drive in Qt?

I m using Qt and want a platform-independent way of getting the available free disk space. I know in Linux I can use statfs and in Windows I can use GetDiskFreeSpaceEx(). I know boost has a way, ...

Drag & drop with .ui files

I m having big troubles with drag & drop. I ve created a new Qt Designer Form Class in which I have one QListWidget and one QWidget. Now I want to enable dragging & dropping between these two ...

Link errors on Snow Leopard

I creating a small desktop application using Qt and Poco on Mac OS X Snow Leopard. Qt works fine, but once I started linking with Poco I get the following warning: ld: warning: in /Developer/SDKs/...

Showing two windows in Qt4

My friend and I have each created parts of a GUI using Qt 4. They both work independently and I am trying to integrate his form with the my main window. As of now this is the code I am using to try ...

Qt equivalent of .NET data binding?

Is there an equivalent of .NET s data binding in Qt? I want to populate some combo boxes and other widgets with QStrings that refer to specific entities in my database. However, it would be cleaner ...

热门标签