27

I am using Debian OS and I'm trying to point to cmake where is my Qt4.

I try to build qjson library and with its CMakeLists.txt: http://pastebin.com/fKNp0Qgy

I get:

Qt5 not found, searching for Qt4
qmake: could not exec '/usr/lib/x86_64-linux-gnu/qt4/bin/qmake': No such file or directory
CMake Error at /usr/share/cmake-2.8/Modules/FindQt4.cmake:1386 (message):
  Found unsuitable Qt version "" from NOTFOUND, this code requires Qt 4.x
Call Stack (most recent call first):
  CMakeLists.txt:55 (FIND_PACKAGE)


-- Configuring incomplete, errors occurred!

I'm not familiar with CMake and Qt config, but I'm curious what setting force CMake FIND_PACKAGE to look into '/usr/lib/x86_64-linux-gnu/qt4/bin/qmake' for qmake. I have installed Qt 4.8.5 from source and I have Qt4 bin folder in completely different directory.

0

8 Answers 8

23

just try "sudo apt-get install qt-sdk" it works for me

3
  • 3
    Not a solution on Ubuntu 14.04. Commented Jan 11, 2016 at 16:54
  • 2
    2020 tested: apt-get install qt4-default Commented Mar 22, 2020 at 11:02
  • 2
    The qt-sdk package doesn't exist anymore. we should install libqt4-dev instead. Commented Apr 6, 2020 at 20:58
12

I solved my problem.

Looking for QT_SELECT with grep command I found that QT_SELECT is related to /usr/lib/x86_64-linux-gnu/qt-default/qtchooser/default.conf file. From the "default" file name I assumed that it is what is seen as QT_SELECT. Other configs presented with qtchooser -l are in /usr/share/qtchooser/ and /usr/lib/x86_64-linux-gnu/qtchooser directories.

Such a config file has two lines with paths. I just changed these lines, first pointing to my Qt bin directory and second pointing to my Qt lib directory. Then I could see that qtchooser -print-env shows QTTOOLDIR and QTLIBDIR to my Qt.

Then I could easily build qjson library with CMake, Qt4 was found correctly.

1
  • Awesome. This worked on Ubuntu 16.04 with Qt4. Note that those config files, while seemingly scattered between /usr/share/... and /usr/lib/..., all except one are symlinks to the actual config in /usr/share/qtchooser/qt4-x86_64-linux-gnu.conf. So only needs to be changed there.
    – Cosmo
    Commented Nov 20, 2019 at 1:44
8

In my experience, this problem is most easily solved by putting the folder containing qmake in your PATH environment variable.

4
  • 1
    When I add this folder to PATH it still wants this '/usr/lib/x86_64-linux-gnu/qt4/bin/qmake', not my '/home/daniel/Programy/qt-everywhere-opensource-src-4.8.5/bin/qmake'
    – bLAZ
    Commented Mar 1, 2014 at 11:37
  • Maybe it will be useful info that directory '/usr/lib/x86_64-linux-gnu/qt4/bin' exists in my system, but there is only 'qdbus' file.
    – bLAZ
    Commented Mar 1, 2014 at 11:47
  • Ok. I see there is a tool 'qtconfig'. It shows me $ qtchooser -print-env QT_SELECT="default" QTTOOLDIR="/usr/lib/x86_64-linux-gnu/qt4/bin" QTLIBDIR="/usr/lib/x86_64-linux-gnu" I have to figure out how to point to my qt version.
    – bLAZ
    Commented Mar 1, 2014 at 12:57
  • My experience is actually with Qt5 - maybe CMake treats Qt4 differentlY? Commented Mar 1, 2014 at 13:28
3

Here is the answers

https://askubuntu.com/questions/540746/ubuntu-14-04-qt5-development-libraries/540757#540757

Seems

apt-file search Qt5CoreConfig.cmake was what I was missing. This got me:

qtbase5-dev: /usr/lib/x86_64-linux-gnu/cmake/Qt5Core/Qt5CoreConfig.cmake

Installing that seems to lead to CMake finding Qt5. qmake still reports the same problem when directly called though...some remnant from qt4 still installed it seems...

As for the qmake problem, this is fixed by:

sudo apt-get install qt5-default
1

In my case it was just that qtchooser was missing the "default" configuration. I figured cmake is just executing qtchooser and looking for a "default" configuration file name. You can install any configuration file by doing the following:

qtchooser -install <arbitrary_name> <path_to_qmake>

In my case I simply provided "default" as the arbitrary name... this created the default.conf file in the appropriate locations and all is well. I don't think there is a limit to how many named versions of qt you have. If you do this as root it should work for all users.

1

On my old RHEL distro, this did it for me:

sudo yum install qt-devel.x86_64

Just the qt-base one wouldn't work with cmake.

1

1) Where is your qtchooser configuration file?

  $: locate qtchooser | grep conf

2) From the list of conf files, probably there is one call "default.conf" This one is a link to one of the others (4.conf or qt4.conf or 5.conf or qt5.conf). Choose the one that makes sense too you, and create a link to it.

Suppose your default file path is

/usr/lib/x86_64-linux-gnu/qt-default/qtchooser/default.conf

Create backup:

  $: cd $(dirname /usr/lib/x86_64-linux-gnu/qt-default/qtchooser/default.conf)
  $: cp -av default.conf default.conf_backup

Let's say you target is /usr/lib/x86_64-linux-gnu/qtchooser/qt5.conf

Then:

  $: sudo ln -s /usr/lib/x86_64-linux-gnu/qtchooser/qt5.conf default.conf

3) Is the path to your qmake right?

Check qmake location

  $: locate qmake | grep bin

Is the same one as indicated in your modified qtchooser/default.conf?

  $: cat /usr/lib/x86_64-linux-gnu/qtchooser/qt5.conf

If the answer is YES, then you are done. If the anser is no, then you need to modify the file:

Create backup:

  $: cd $(dirname /usr/lib/x86_64-linux-gnu/qtchooser/qt5.conf)
  $: cp -av qt5.conf qt5.conf_backup

Edit file and change path to your qmake location

  $ sudo vi qt5.conf

Now it should be done.

0

Simplest solution was add a link in the directory that the gem expected to find it. On Ubuntu 14.04 it qmake lives in /usr/bin. Simple solution.

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