I am quite new to linux and I am using Ubuntu 16.04 LTS 64bits.
I acquired an open source code, and I need to compile it with cmake. This code required QT4.
I downloaded a QT4.8.6 open source files and manually compiled them. (this is needed because QT no longer support pre-compiled QT4 for linux).
I added my "qmake" directory to my PATH variable. echo ${PATH} shows that.
When I compile the code with CMAKE, the following error appears :
CMake Error at /usr/share/cmake-3.5/Modules/FindPackageHandleStandardArgs.cmake:148 (message): Could NOT find Qt4 (missing: QT_MOC_EXECUTABLE QT_RCC_EXECUTABLE QT_UIC_EXECUTABLE) (found version "4.8.6") Call Stack (most recent call first):
/usr/share/cmake-3.5/Modules/FindPackageHandleStandardArgs.cmake:388 (_FPHSA_FAILURE_MESSAGE)
/usr/share/cmake-3.5/Modules/FindQt4.cmake:1333 (FIND_PACKAGE_HANDLE_STANDARD_ARGS) CMakeLists.txt:20 (FIND_PACKAGE)
Help is much appreciated.
You don't need to download Qt 4 from qt.io, Ubuntu 16.04 has both Qt 4.8.7 and Qt 5.5.1 compiled and available in the repositories
cmake finds Qt by looking for the qmake
binary and other binaries. Unfortunately both Qt5 and Qt4 have those binaries, and Ubuntu solves that problem by installing Qt4 to /usr/lib/x86_64-linux-gnu/qt4
. You can make Qt4 the default (the one in your path) by installing the package qt4-default
: sudo apt install qt4-default
which will create symlinks from the qt4-specific folder (for example for qmake from /usr/lib/.../qt4/bin/qmake
to /usr/bin/qmake
. Now, qmake --version
should print Using Qt version 4.8.7 in /usr/lib/x86_64-linux-gnu
This only applies when you use cmake on the command line. If you use QtCreator, your Kit configuration will apply.
I think the easiest way to solve your problem is just using the Qt 4 supplied by Ubuntu (by installing qt4-default
), and removing your custom build Qt 4 and the PATH modifications.