CMake doesn't know where is Qt4 qmake

2019-03-14 11:36发布

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.

标签: linux qt cmake
8条回答
Deceive 欺骗
2楼-- · 2019-03-14 11:59

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.

查看更多
啃猪蹄的小仙女
3楼-- · 2019-03-14 12:03

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

查看更多
何必那么认真
4楼-- · 2019-03-14 12:04

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
查看更多
5楼-- · 2019-03-14 12:07

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

查看更多
可以哭但决不认输i
6楼-- · 2019-03-14 12:09

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.

查看更多
闹够了就滚
7楼-- · 2019-03-14 12:11

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.

查看更多
登录 后发表回答