PDA

View Full Version : Build a release version of QT app with the static libraries of QT



rakefet
21st March 2014, 12:55
Hi,

The problem I have is that I can not build a static version of a simple QT application.

I have on my computer two versions of Qt5. One version was built with the default setting (dynamic libs) and the other version was built with the static option. I put each version in different location on my computer.
I built a simple qt app in qt creator. The .pro file looks like that:

QT += core gui
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets

TARGET = mydialog


TEMPLATE = app


SOURCES += main.cpp\
mydialog.cpp

HEADERS += mydialog.h

FORMS += \
mydialog.ui


CONFIG += static
static {
CONFIG += static
DEFINES += STATIC
message("Static build.")
}

I changed the qt version on qt_creator to look at the location of qmake.exe at the location of the qt with the static version.
When I run qmake from qt_creator I am getting the error: Error while building/deploying project mydialog When executing step 'qmake'.

When I run qmake from the command line qmake creates Makefile but the Makefile points into the qt libraries in the dynamic version.

I want to point out that in my computer the path and QDIR are set to be the location of the dynamic version of QT.

I would like to be able to link the dynamic version of qt in the debug version of the project and the static version of qt in the release version of my project.

How can I do that?

Thank you in advance,

anda_skoa
21st March 2014, 13:45
When you run qmake on the command line, do you run the correct version? I.e. the one from the static build?

Cheers,

wysota
21st March 2014, 13:54
You can check which version of qmake you use by running qmake -v

rakefet
21st March 2014, 14:16
Yes. When I type qmake -v , I am getting the qmake with the static version.
I changed my computer environment path to the static version and now the Makefile points to the right version. However, when I tried to build the project, I've got errors in the qtcore header. Since I built the static version with source that was taken from git last week and could have bugs in it, I am going now to build the static version with the same source that I was building the dynamic version and see what happens. I'll keep you posted.