4

I have installed Qt 5.6 from the official website via a *.run file. The installation directory is in my home folder. When I run

qmake --version

I get the following message:

qmake: could not exec '/usr/lib/x86_64-linux-gnu/qt4/bin/qmake': No such file or directory

I think the problem is that the operating system does not look for the qmake in the correct directory (I have Qt installed in my home folder).

How can I tell the operating system to search for Qt in my home folder?

4
  • I have two folders in "/usr/lib/x86_64-linux-gnu/" named qt4 and qt5. The default searching directory is in qt4, while I have qt5 installed. It does not seem a good choice to create a link in qt4 while I have qt5. There should be a way to tell the operating system to search in the desired folder.
    – Unique
    Jul 21 '17 at 14:15
  • 2
    Well OK hold on a second though. Why did you install via the .run file? That is not the recommended way to install software on Linux. Why didn't you use apt-get? Jul 21 '17 at 14:17
  • 2
    apt-get would have updated alternatives, right now it does not know that qt5 is installed
    – ravery
    Jul 21 '17 at 14:24
  • Well, I was searching for a specific version of Qt and I found it in the official website. There was not a .deb file and I did not know how to select the version of Qt using apt-get.
    – Unique
    Jul 21 '17 at 14:25
9

The solution lies in using update-alternatives(8). For more information on the reasoning behind it, refer to What exactly does `update-alternatives` do?

sudo update-alternatives --install /usr/bin/qmake qmake /usr/lib/x86_64-linux-gnu/qt5/bin/qmake 100

followed by:

sudo update-alternatives --config qmake

to make sure the qt5 version is being used. This will update /usr/bin/qmake to point to the qt5 version.

A side note: You may need to check /usr/bin/ to see if there is already a symlink. If it is not managed by update-alternatives then you may need to manually remove or rename it for this to work.

Hope that helps!

5
  • And don't forget to check the right version of the manpage. I linked the LTS, but use the one that applies. Jul 21 '17 at 14:49
  • That's great. Thanks. By the way, I had the Qt installed in my home folder, so the command line that I used is like this: "sudo update-alternatives --install /usr/bin/qmake qmake <QT_DIRECTORY>/bin/qmake 100"
    – Unique
    Jul 21 '17 at 15:00
  • Yes, I figured you would update the info to be pertinent. Glad it helped. Jul 21 '17 at 15:23
  • This works on KDE neon 5.14. Honestly, I don't know what caused this nor I remember anything I did. Dec 11 '18 at 5:37
  • 2
    On Ubuntu 18.04, I get update-alternatives: error: alternative path /usr/lib/x86_64-linux-gnu/qt5/bin/qmake doesn't exist. Oct 22 '19 at 6:28
0

This worked for me:

sudo apt-get install qt4-qmake libqt4-dev

Followed by:

sudo update-alternatives --install /usr/bin/qmake qmake /usr/lib/x86_64-linux-gnu/qt4/bin/qmake 100

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.