Force compilation with qt4 even if qt5 is installed

十年热恋 提交于 2020-01-06 04:25:18

问题


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


回答1:


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})


来源:https://stackoverflow.com/questions/23841444/force-compilation-with-qt4-even-if-qt5-is-installed

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!