[QT][?] Found unsuitable Qt version "5.0.2" from /usr/bin/qmake, this code requires Qt 4.x
来源:互联网 发布:好用的眼部精华 知乎 编辑:程序博客网 时间:2024/06/03 13:09
1. 调试 错误: Found unsuitable Qt version "5.0.2" from /usr/bin/qmake, this code requires Qt 4.x
CMake Error at /usr/share/cmake-2.8/Modules/FindQt4.cmake:1193 (MESSAGE):
Found unsuitable Qt version "5.0.2" from /usr/bin/qmake, this code requires Qt 4.x
Call Stack (most recent call first): ros_tutorials-hydro-devel/turtlesim/CMakeLists.txt:6 (find_package)
执行下面的命令 : sudo apt-get install qt4-default
The following packages will be REMOVED:
qt5-default
The following NEW packages will be installed:
qt4-default
sudo apt-get install qt5-default
2. usr/bin/ld: cannot open output file test: Is a directory
提示错误
/usr/bin/ld: cannot open output file test: Is a directory
collect2: ld returned 1 exit status
文件夹同名问题。
SET(main_src_SOURCES ${treebot_SOURCE_DIR}/main_src/mainwindow.cpp ${treebot_SOURCE_DIR}/main_src/serialport.cpp ${treebot_SOURCE_DIR}/main_src/util.cpp ${treebot_SOURCE_DIR}/main_src/slidervelocity.cpp )SET(main_src_HEADERS ${treebot_SOURCE_DIR}/main_src/mainwindow.h ${treebot_SOURCE_DIR}/main_src/serialport.h ${treebot_SOURCE_DIR}/main_src/treerobotconstant.h ${treebot_SOURCE_DIR}/main_src/slidervelocity.h ${treebot_SOURCE_DIR}/main_src/util.h)QT5_WRAP_CPP(main_src_HEADERS_MOC ${main_src_HEADERS})QT5_WRAP_CPP 时会在编译路径build下生成main_src 文件夹存放相应的cmake缓存。
而我又有这样的执行文件需生成 main_src ; 造成同名使得无法生成执行文件main_src.
add_executable(main_src ${treebot_SOURCE_DIR}/main_src/main.cpp # ${treebot_SOURCE_DIR}/qrslam/CameraEstimation.cpp # ${treebot_SOURCE_DIR}/qrslam/CameraEstimation.h ${main_src_SOURCES} ${main_src_HEADERS_MOC} ${main_src_HEADERS} ${main_src_UI_HEADERS} )TARGET_LINK_LIBRARIES(main_src ${Qt5Core_LIBRARIES} ${Qt5Widgets_LIBRARIES} ${Qt5Gui_LIBRARIES} ${Qt5SerialPort_LIBRARIES} CameraEstimation )
解决方法:
1).设置编译路径路径;
设置输出文件路径: 执行文件则生成在/bin内 set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/bin) set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/lib) set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/lib)
2). 改生成执行文件命名。
add_executable(treebot ${treebot_SOURCE_DIR}/main_src/main.cpp # ${treebot_SOURCE_DIR}/qrslam/CameraEstimation.cpp # ${treebot_SOURCE_DIR}/qrslam/CameraEstimation.h ${main_src_SOURCES} ${main_src_HEADERS_MOC} ${main_src_HEADERS} ${main_src_UI_HEADERS} )TARGET_LINK_LIBRARIES(treebot ${Qt5Core_LIBRARIES} ${Qt5Widgets_LIBRARIES} ${Qt5Gui_LIBRARIES} ${Qt5SerialPort_LIBRARIES} CameraEstimation )
3. qt5_wrap_ui生成的头文件 ui_mainwindow.h 中#include "slidervelocity.h"文件出错。
#CMakeLists.txt中 qt5_wrap_ui(main_src_UI_HEADERS ${treebot_SOURCE_DIR}/main_src/mainwindow.ui)
<span style="color:#be1414;">//ui_mainwindow.h</span>中#include <QtWidgets/QToolBar>#include <QtWidgets/QWidget>#include "slidervelocity.h"
问题原因:主要是cmake生成的路径在build,即 qt5_wrap_ui 命令生成的文件ui_mainwindow.h 在build中,而 slidervelocity.h 在main_src 文件夹下。
解决方法:
1) 直接改ui_mainwindow.h 的include说明
#include "../main_src/slidervelocity.h"这种方式比较愚笨,而是想直接通过cmakelists的形式完成。
2) 在cmakelists中加入包含文件路径
include_directories(${treebot_SOURCE_DIR}/main_src)则在<span style="color:#be1414;">ui_mainwindow.h</span>就可以识别下面包含文件#include "slidervelocity.h"
3) 改变 qt5_wrap_ui生成文件的路径,让其生成的slidervelocity.h ui_mainwindow.h 文件位置到 main_src ,与 slidervelocity.h在同一文件夹。
- [QT][?] Found unsuitable Qt version "5.0.2" from /usr/bin/qmake, this code requires Qt 4.x
- 关于Qt中qmake 的路径是/usr/bin/qmake 的解决办法
- 关于Qt中qmake 的路径是/usr/bin/qmake 的解决办法
- The process "E:\Qt\4.8.5\bin\qmake.exe" exited with code 2.
- qt /usr/bin/ld: cannot find -lGL
- Qt::/usr/bin/ld: 找不到 -lGL
- QT /usr/bin/ld: cannot find -lGL
- The Transition from Qt 4.x to Qt 5
- The Transition from Qt 4.x to Qt 5
- QT中的qmake详解
- QT中的qmake详解
- qt qmake moc pro
- QT中的qmake详解
- linux-qt-qmake
- QT的qmake流程
- qt之qmake
- Qt之使用qmake
- Qt中文路径问题(Cannot find file: 进程"C:\Qt\4.8.5\bin\qmake.exe"退出,退出代码 2)
- USACO2.4.2 Overfencing (maze1)
- Hive 研发笔记---LEFT JOIN 中的坑
- Java枚举和注解
- EBS业务学习之应付INVOICE类型
- Linux GCC常用命令
- [QT][?] Found unsuitable Qt version "5.0.2" from /usr/bin/qmake, this code requires Qt 4.x
- Android UI编程之自定义控件初步(上)——ImageButton
- 客户相关概念介绍
- 添加行间距时设置字体
- 【设计模式】抽象工厂模式
- U3D基本方法
- 单例模式
- 百度基础地图Android SDK应用demo--便民服务
- android清除缓存