How to work with different versions of Qt on the same machine?

6.1k Views Asked by At

I have problems since I installed both Qt 4.8.4 and Qt 5.1 on my computer.

When only Qt 4.8.4 was present, everything was fine.

When I added Qt 5.1, this one is working properly, but Qt 4.8.4 gives me these linker errors:

Makefile:34: recipe for target 'debug' failed
c:/mingw/bin/../lib/gcc/mingw32/4.7.2/../../../../mingw32/bin/ld.exe: cannot find -lQtGuid
c:/mingw/bin/../lib/gcc/mingw32/4.7.2/../../../../mingw32/bin/ld.exe: cannot find -lQtCored
collect2.exe: error: ld returned 1 exit status
mingw32-make[1]: *** [debug/BuildSystemTest3.exe] Error 1
mingw32-make: *** [debug] Error 2
09:21:00: The process "C:\MinGW\bin\mingw32-make.exe" exited with code 2.
Error while building/deploying project BuildSystemTest3 (kit: Desktop)
When executing step 'Make'

I could replicate the problem on a trivial test project (the one created by QtCreator by default), with this pro file:

QT += core gui

greaterThan(QT_MAJOR_VERSION, 4): QT += widgets

TARGET = BuildSystemTest3
TEMPLATE = app

SOURCES += main.cpp mainwindow.cpp
HEADERS += mainwindow.h

The two Qt versions are installed in two separate directories: C:\Qt\4.8.4 and C:\Qt\Qt5.1.0
MinGW is a link to either MinGW_4.6.2 (for Qt4) or MinGW_4.7.2 (for Qt5).

Can different versions of Qt coexist on the same computer? How?

1

There are 1 best solutions below

2
On

I think there might be a problem with the QTDIR environment variable pointing to the 5.1 installation.

You could create two batch files like this (might have to add full path to qtcreator.exe):

qtcreator484.bat:

set QTDIR=C:\Qt\4.8.4
start qtcreator.exe

qtcreator510.bat:

set QTDIR=C:\Qt\5.1.0
start qtcreator.exe

and place them e.g. on your desktop. Then always start QtCreator via the batch files for the configuration you want.

Side node: There are sometimes problems when having two QtCreator instances up at the same time, e.g. the second instance cannot write to the console.