首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Qt5 cmake找不到ui的头文件

Qt5 cmake找不到ui的头文件
EN

Stack Overflow用户
提问于 2017-04-20 16:29:42
回答 2查看 1.5K关注 0票数 2

我正在为我的Qt5应用程序创建一个cmake项目。现在,当我在Clion中使用cmake编译我的应用程序时,我得到了一个致命的错误。

我的CMakeLists.txt文件看起来如下:

代码语言:javascript
复制
 cmake_minimum_required(VERSION 2.8.11)

project(Oefening11_kv)

# Find includes in corresponding build directories
set(CMAKE_INCLUDE_CURRENT_DIR ON)
# Instruct CMake to run moc automatically when needed.
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTOUIC ON)

set (CMAKE_PREFIX_PATH C:\\Qt\\Qt5.8.0\\5.8\\mingw53_32\\lib\\cmake\\)

# Find the Qt libraries
find_package(Qt5Core REQUIRED)
find_package(Qt5Widgets)
find_package(Qt5Gui)
find_package(Qt5Charts)

set(Oefening11_kv_SOURCES main.cpp oefening11a.cpp oefening11b.cpp oefening11c.cpp)
set(Oefening11_kv_HEADERS oefening11a.h oefening11b.h oefening11c.h)
set(Oefening11_kv_FORMS oefening11a.ui)

QT5_WRAP_CPP(Oefening11_kv_HEADERS_MOC ${Oefening11_kv_HEADERS})
QT5_WRAP_UI(Oefening11_kv_FORMS_HEADERS ${Oefening11_kv_FORMS})

add_library(Oefening11_kv_CONFIG ${Oefening11_kv_HEADERS_MOC} ${Oefening11_kv_FORMS_HEADERS})
QT5_USE_MODULES(Oefening11_kv_CONFIG Widgets)

add_executable(Oefening11_kv ${Oefening11_kv_SOURCES} ${Oefening11_kv_CONFIG})
QT5_USE_MODULES(Oefening11_kv Core Gui Widgets Charts)

在编译应用程序时,Clion正在处理的错误是:

__imp__ZN8QtCharts11QLineSeriesC1EP7QObject' oefening11a.cpp:26: undefined reference to__imp__ZN8QtCharts9QXYSeries6appendEdd‘oefening11a.cpp:30的未定义引用:对__imp__ZN8QtCharts6QChartC1EP13QGraphicsItem6QFlagsIN2Qt10WindowTypeEE' oefening11a.cpp:31: undefined reference to的未定义引用、对__imp__ZNK8QtCharts6QChart6legendEv' oefening11a.cpp:33: undefined reference to__imp__ZN8QtCharts6QChart8setTitleERK7QString’oefening11a.cpp:36的未定义引用:对__imp__ZN8QtCharts10QValueAxisC1EP7QObject' oefening11a.cpp:37: undefined reference to __imp__ZN8QtCharts10QValueAxis14setLabelFormatERK7QString‘oefening11a.cpp:38的未定义引用:对__imp__ZN8QtCharts13QAbstractAxis12setTitleTextERK7QString' oefening11a.cpp:39: undefined reference to __imp__ZN8QtCharts6QChart7addAxisEPNS的未定义引用_13QAbstractAxisE6QFlagsIN2Qt13AlignmentFlagEE‘oefening11a.cpp:40:对__imp__ZN8QtCharts15QAbstractSeries10attachAxisEPNS_13QAbstractAxisE' oefening11a.cpp:43: undefined reference to __imp__ZN8QtCharts10QValueAxisC1EP7QObject’oefening11a.cpp:44的未定义引用:对__imp__ZN8QtCharts10QValueAxis14setLabelFormatERK7QString' oefening11a.cpp:45: undefined reference to __imp__ZN8QtCharts10QValueAxisC1EP7QObject oefening11a.cpp:46的未定义引用:对__imp__ZN8QtCharts6QChart7addAxisEPNS_13QAbstractAxisE6QFlagsIN2Qt13AlignmentFlagEE' oefening11a.cpp:47: undefined reference to __imp__ZN8QtCharts15QAbstractSeries10attachAxisEPNS_13QAbstractAxisE‘oefening11a.cpp:50的未定义引用:对__imp__ZN8QtCharts10QChartViewC1EPNS_6QChartEP7QWidget' oefening11a.cpp:51: undefined reference to __imp__ZN13QGraphicsView13setRenderHintEN8QPainter10RenderHintEb’oefening11a.cpp:54的未定义引用:对<代码>D11QMainWindow::event(QEvent*)' t_automoc.cpp:(.rdata$_ZTV11Oefening11A[_ZTV11Oefening11A]+0x40): undefined reference toQObject::eventFilter(QObject*,的引用‘t_automoc.cpp:(.rdata$_ZTV11Oefening11A_ZTV11Oefening11A+0x48):未定义引用QObject::timerEvent(QTimerEvent*)' t_automoc.cpp:(.rdata$_ZTV11Oefening11A[_ZTV11Oefening11A]+0x50): undefined reference toQObject::childEvent(QChildEvent*)’t_automoc.cpp:(.rdata$_ZTV11Oefening11A_ZTV11Oefening11A+0x58):未定义引用QObject::customEvent(QEvent*)' t_automoc.cpp:(.rdata$_ZTV11Oefening11A[_ZTV11Oefening11A]+0x60): undefined reference toQObject::connectNotify(QMetaMethod const&) t_automoc.cpp:(.rdata$_ZTV11Oefening11A_ZTV11Oefening11A+0x68):未定义引用QObject::disconnectNotify(QMetaMethod const&)' t_automoc.cpp:(.rdata$_ZTV11Oefening11A[_ZTV11Oefening11A]+0x70): undefined reference toQWidget::devType() const‘t_automoc.cpp:(.rdata$_ZTV11Oefening11A_ZTV11Oefening11A+0x78):未定义的对t_automoc.cpp:(.rdata$_ZTV11Oefening11A_ZTV11Oefening11A+0x98):QWidget的引用::QWidget::setVisible(bool)' t_automoc.cpp:(.rdata$_ZTV11Oefening11A[_ZTV11Oefening11A]+0x80): undefined reference toQWidget::t_automoc.cpp:(.rdata$_ZTV11Oefening11A_ZTV11Oefening11A+0xa8):未定义的对QWidget::mousePressEvent(QMouseEvent*)' t_automoc.cpp:(.rdata$_ZTV11Oefening11A[_ZTV11Oefening11A]+0xb0): undefined reference toQWidget::mouseReleaseEvent(QMouseEvent*)‘t_automoc.cpp的引用:(.rdata$_ZTV11Oefening11A_ZTV11Oefening11A+0xb8):未定义引用QWidget::mouseDoubleClickEvent(QMouseEvent*)' t_automoc.cpp:(.rdata$_ZTV11Oefening11A[_ZTV11Oefening11A]+0xc0): undefined reference toQWidget::mouseMoveEvent(QMouseEvent*)‘t_automoc.cpp:(.rdata$_ZTV11Oefening11A_ZTV11Oefening11A+0xc8):未定义引用QWidget::wheelEvent(QWheelEvent*)' t_automoc.cpp:(.rdata$_ZTV11Oefening11A[_ZTV11Oefening11A]+0xd0): undefined reference toQWidget::keyPressEvent(QKeyEvent*)’t_automoc.cpp:(.rdata$_ZTV11Oefening11A_ZTV11Oefening11A+0xd8):未定义引用QWidget::keyReleaseEvent(QKeyEvent*)' t_automoc.cpp:(.rdata$_ZTV11Oefening11A[_ZTV11Oefening11A]+0xe0): undefined reference toQWidget::focusInEvent(QFocusEvent*)‘t_automoc.cpp:(.rdata$_ZTV11Oefening11A_ZTV11Oefening11A+0xe8):未定义引用QWidget::focusOutEvent(QFocusEvent*)' t_automoc.cpp:(.rdata$_ZTV11Oefening11A[_ZTV11Oefening11A]+0xf0): undefined reference toQWidget::enterEvent(QEvent*) t_automoc.cpp:(.rdata$_ZTV11Oefening11A_ZTV11Oefening11A+0xf8):未定义引用QWidget::leaveEvent(QEvent*)' t_automoc.cpp:(.rdata$_ZTV11Oefening11A[_ZTV11Oefening11A]+0x100): undefined reference toQWidget::paintEvent(QPaintEvent*)‘t_automoc.cpp:(.rdata$_ZTV11Oefening11A_ZTV11Oefening11A+0x108):未定义引用QWidget::moveEvent(QMoveEvent*)' t_automoc.cpp:(.rdata$_ZTV11Oefening11A[_ZTV11Oefening11A]+0x110): undefined reference toQWidget::resizeEvent(QResizeEvent*)’t_automoc.cpp:(.rdata$_ZTV11Oefening11A_ZTV11Oefening11A+0x118):未定义引用QWidget::closeEvent(QCloseEvent*)' t_automoc.cpp:(.rdata$_ZTV11Oefening11A[_ZTV11Oefening11A]+0x120): undefined reference to QMainWindow::contextMenuEvent(QContextMenuEvent*)‘t_automoc.cpp:(.rdata$_ZTV11Oefening11A )):未定义引用QWidget::tabletEvent(QTabletEvent*)' t_automoc.cpp:(.rdata$_ZTV11Oefening11A[_ZTV11Oefening11A]+0x130): undefined reference toQWidget::actionEvent(QActionEvent*)‘t_automoc.cpp:(.rdata$_ZTV11Oefening11A_ZTV11Oefening11A+0x138):未定义引用QWidget::dragEnterEvent(QDragEnterEvent*)' t_automoc.cpp:(.rdata$_ZTV11Oefening11A[_ZTV11Oefening11A]+0x140): undefined reference toQWidget::dragMoveEvent(QDragMoveEvent*)’t_automoc.cpp:(.rdata$_ZTV11Oefening11A_ZTV11Oefening11A+0x148):未定义引用QWidget::dragLeaveEvent(QDragLeaveEvent*)' t_automoc.cpp:(.rdata$_ZTV11Oefening11A[_ZTV11Oefening11A]+0x150): undefined reference toQWidget::dropEvent(QDropEvent*)‘t_automoc.cpp:(.rdata$_ZTV11Oefening11A_ZTV11Oefening11A+0x158):未定义引用QWidget::showEvent(QShowEvent*)' t_automoc.cpp:(.rdata$_ZTV11Oefening11A[_ZTV11Oefening11A]+0x160): undefined reference toQWidget::hideEvent(QHideEvent*)’t_automoc.cpp:(.rdata$_ZTV11Oefening11A_ZTV11Oefening11A+0x168):未定义引用QWidget::nativeEvent(QByteArray const&, void*, long*)' t_automoc.cpp:(.rdata$_ZTV11Oefening11A[_ZTV11Oefening11A]+0x170): undefined reference toQWidget::changeEvent(QEvent*)‘t_automoc.cpp:(.rdata$_ZTV11Oefening11A_ZTV11Oefening11A+0x178):未定义引用QWidget::metric(QPaintDevice::PaintDeviceMetric) const' t_automoc.cpp:(.rdata$_ZTV11Oefening11A[_ZTV11Oefening11A]+0x180): undefined reference toQWidget::initPainter(QPainter*) const’t_automoc.cpp:(.rdata$_ZTV11Oefening11A_ZTV11Oefening11A+0x188):未定义引用QWidget::redirected(QPoint*) const' t_automoc.cpp:(.rdata$_ZTV11Oefening11A[_ZTV11Oefening11A]+0x190): undefined reference toQWidget::sharedPainter() const‘t_automoc.cpp:(.rdata$_ZTV11Oefening11A_ZTV11Oefening11A+0x198):未定义引用到QWidget::inputMethodQuery(Qt::InputMethodQuery) const‘t_automoc.cpp:(.rdata$_ZTV11Oefening11A_ZTV11Oefening11A+0x1a8):未定义引用QWidget::focusNextPrevChild(bool)' t_automoc.cpp:(.rdata$_ZTV11Oefening11A[_ZTV11Oefening11A]+0x1b0): undefined reference toQMainWindow::createPopupMenu()’t_automoc.cpp:(.rdata$_ZTV11Oefening11A_ZTV11Oefening11A+0x1d8):未定义引用对QWidget的non-virtual thunk to QWidget::devType() const' t_automoc.cpp:(.rdata$_ZTV11Oefening11A[_ZTV11Oefening11A]+0x1e0): undefined reference to非虚拟雷击::paintEngine() const‘t_automoc.cpp:(.rdata$_ZTV11Oefening11A_ZTV11Oefening11A+0x1e8):未定义引用non-virtual thunk to QWidget::metric(QPaintDevice::PaintDeviceMetric) const' t_automoc.cpp:(.rdata$_ZTV11Oefening11A[_ZTV11Oefening11A]+0x1f0): undefined reference to非虚拟雷击QWidget::initPainter(QPainter*) const‘t_automoc.cpp:(.rdata$_ZTV11Oefening11A_ZTV11Oefening11A+0x1f8):未定义的对non-virtual thunk to QWidget::redirected(QPoint*) const' t_automoc.cpp:(.rdata$_ZTV11Oefening11A[_ZTV11Oefening11A]+0x200): undefined reference to非虚拟thunk的引用

在我的cmake文件中找不到问题。有人能帮我吗?

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2017-04-21 15:56:46

好吧我发现问题了。我在x86 QT5库上使用了一个QT5编译器。当将编译器更改为x86编译器时,它会编译。

票数 2
EN

Stack Overflow用户

发布于 2017-04-20 16:33:06

除了moc之外,您还需要运行uic

代码语言:javascript
复制
set(CMAKE_AUTOUIC ON)
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/43525049

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档