Force compilation with qt4 even if qt5 is installed - c++

I'm on Ubuntu 14.04 and have both qt4 and qt5 installed (from the repositories). I thought I could switch between building with qt5 to building with qt4 simply with
sudo apt-get install qt4-default
But the program still builds with Qt5 and gives error because it only supports Qt4.
I checked the qmake version and after qt4-default is installed it gives
$ qmake --version
QMake version 2.01a
Using Qt version 4.8.6 in /usr/lib/x86_64-linux-gnu
I'm building with CMake in case that is useful. Also, if I do
sudo apt-get remove qtbase5-dev
then finally it builds with qt4.
EDIT: I am not using Qt Creator and would prefer a command-line solution

You would need to put this into your CMakeLists.txt:
find_package(Qt4 REQUIRED)
...
include_directories(${QT_INCLUDES})
target_link_libraries(main ${QT_QTCORE_LIBRARY})

Related

How to install Qt on MacOS X Sierra and add qmake on terminal

I want to install Qt on my Mac and use the qmake through terminal to compile code. I downloaded the open source Qt Creator from Qt site, but I cannot set it up. Anyone with similar problems?
System: Mac OS X Sierra,
Qt version: 5.7.
I'm downloading the open source installer from qt.io/download-open-source . I'm installing it to Users/MyUserAccount and i want set it up so i can compile C++ code with qmake && make
Just to provide another solution using Homebrew.
As you've found QT4 isn't compatible with Mac OSX Sierra.
You can install QT5 using:
brew install qt5
But you'll find you can't access qmake from the command line. To rectify this you'll need to run:
brew link qt5 --force
If you want to run qmake from command line, add the directory where qmake is located to PATH environment variable. How to do it depends on the shell you are using, for bash it is done by adding export PATH=$PATH:<path_to_qmake> to either ~/.profile, ~/.bash_profile or ~/.bashrc.
For Installing QT4:-
https://github.com/cartr/homebrew-qt4
brew tap cartr/qt4
brew tap-pin cartr/qt4
brew install qt#4
For Installing QT5:-
brew install qt5

How do I deal with qtbase-abi-5-2-1 dependency on Ubuntu?

I build my c++ Qt app on Mint 17.2, using debuild. The $shlibs variable expands to include qtbase-abi-5-2-1. Does that mean one of the dependent shared libraries is using Qt private headers? I'm not using private headers explicitly in my app.
In my .pro I have:
QT += printsupport
QT += widgets svg xmlpatterns network concurrent
Could one of those be causing this dependency?
The problem is my .deb won't install on Ubuntu 15.10 because it can't handle this dependency, since Ubuntu 15.10 comes with a later version of Qt.
Linking Qt statically is not an option for me. So what options do I have? Is there some way I can include libqt5core5a in my deb, and Ubuntu 15.10 will be happy? Or if I use a later version of Qt 5 to build, will the dependency on qtbase-abi-x-x-x go away (for instance, build on Ubuntu 15.10 which uses Qt 5.4.1 I believe, and future releases of Ubuntu won't complain about qtbase-abi-5-4-1)?
EDIT:
I tried building on Ubuntu 15.10, and I have the same problem: the executable is dependent on qtbase-abi-5-4-2.
In case it's helpful, I set up my build machine with this:
sudo apt-get install g++ subversion build-essential devscripts
debhelper libicu-dev qtbase5-dev qt5-default libqt5svg5-dev
libqt5xmlpatterns5-dev qttools5-dev-tools

Unknown module(s) in QT: multimedia

I have downloaded qt-everywhere-opensource-src-5.4.1 and build and installed static.
Next i built QMultimedia and installed.
I get "Unknown module(s) in QT: multimedia" from the .pro when including
QT += multimedia.
I have QtMultimedia,QtMultimediaQuick_p and QtMultimediaWidgets in /usr/local/Qt-5.4.1/include.
Also have mediaservice,playlistformats in /usr/local/Qt-5.4.1/plugins
Also have QtMobility,QtMultimediaKit in /usr/include
I am running Ubuntu 15.0
All related issues i've found did not help.
Please run:
sudo apt-get install qtmultimedia5-dev
afterwards you can install other multimedia packages as needed, but this enables the multimedia in general.

How do i Upgrade from Qt5 to Qt5.4 on Linux?

My OS is Kubuntu 14.04.
I installed Qt5 via apt-get install libqt5-dev
How can i upgrade my Qt to the new Version of Qt(5.4)? I could install it manually but then the files in usr/include etc. are not updated and CMake is always searching there first, therefore not the newest Version will be picked. Is there a way to do something like make install to upgrade the existing Qt Version that will be used as default?

Qt 4.8.4 (i386/x64) on Ubuntu 13.04 x64

Is there way to keep both x64/x86 packages for qt 4.8.4 on one linux machine?
For example, when I'm trying to install qt4 bin package:
sudo apt-get install libqt4-dev-bin:i386
I only get warning:
The following packages will be REMOVED: libqt4-dev-bin
The same thing for qt4-qmake and other qt4 packages.
Thanks!