PDA

View Full Version : qmake' s CONFIG variable' s oddity, you will hardly believe it.



Quicksort
16th February 2012, 03:07
Platforms: Win7 x64, Linux x64 (Fedora 15)

OK, I am a newcomer to Qt but there are things which simply do not make sense:

Under Linux (standard dynamic Qt installation):

With the following project file:

CONFIG = qt
TEMPLATE = app
HEADERS = Qt_Test.h
SOURCES = Qt_Test.cpp

My test program runs fine.

With this one:

CONFIG += qt
TEMPLATE = app
HEADERS = Qt_Test.h
SOURCES = Qt_Test.cpp

It crashes (std::bad_alloc exception or general protection fault)

With this one:

CONFIG = qt
CONFIG += debug
TEMPLATE = app
HEADERS = Qt_Test.h
SOURCES = Qt_Test.cpp

or this one:

CONFIG = qt
CONFIG += release
TEMPLATE = app
HEADERS = Qt_Test.h
SOURCES = Qt_Test.cpp

or this one:

CONFIG = qt
CONFIG += debug_and_release
TEMPLATE = app
HEADERS = Qt_Test.h
SOURCES = Qt_Test.cpp

it also crashes.

Now, under Windows (static Qt build from source) if I try what works under Linux, namely the first project file:

CONFIG = qt
TEMPLATE = app
HEADERS = Qt_Test.h
SOURCES = Qt_Test.cpp

The linker signals about one hundred unresolved externals.

It will accept this :

CONFIG += qt
TEMPLATE = app
HEADERS = Qt_Test.h
SOURCES = Qt_Test.cpp

...but the program will crash.

ChrisW67
16th February 2012, 03:22
The CONFIG variable contains a bunch of stuff by default, which is why all the examples in the docs are always:


CONFIG += whatever


The crashing of your program is impossible to diagnose because you failed to provide it.

MarekR22
16th February 2012, 11:43
For testing, pro file should look like this (Qt Creator generates that):

QT += testlib
QT -= gui
TARGET = tst_sometest
CONFIG += console
CONFIG -= app_bundle

TEMPLATE = app

SOURCES += tst_funytest.cpp
DEFINES += SRCDIR=\\\"$$PWD/\\\"

In general CONFIG contains files (*.prf) names (without extensions) located at <qt location>/mkspecs/features/ . Content of those files is "included" to the project.