2017-04-20 486 views
0

我正在創建Qt5應用程序的cmake項目。現在,當我在Clion中使用cmake編譯我的應用程序時,我得到了一個致命錯誤。Qt5 cmake找不到UI的頭文件

我的CMakeLists.txt文件看起來像:

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) 

當我編譯的應用程序,克利翁被trowing的錯誤是:

oefening11a.cpp:21:未定義參考 __imp__ZN8QtCharts11QLineSeriesC1EP7QObject' oefening11a.cpp:26: undefined reference to __imp__ZN8QtCharts9QXYSeries6appendEdd' oefening11a.cpp:30:undefined reference to __imp__ZN8QtCharts6QChartC1EP13QGraphicsItem6QFlagsIN2Qt10WindowTypeEE' oefening11a.cpp:31: undefined reference to __imp__ZN8QtCharts6QChart9addSeriesEPNS_15QAbstract SeriesE ' oefening11a.cpp:32:未定義參照 __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__ZN8QtCharts13QAbstractAxis12setTitleTextERK7QString' 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:未定義參照 __imp__ZN11QMainWindow16setCentralWidgetEP7QWidget' oefening11a.cpp:73: undefined reference to __imp__ZN10QStatusBar11showMessageERK7QStringi」 t_automoc.cpp :(RDATA $。 _ZTV11Oefening11A [_ZTV11Oefening11A] + 0x38): 未定義參照QMainWindow::event(QEvent*)' t_automoc.cpp:(.rdata$_ZTV11Oefening11A[_ZTV11Oefening11A]+0x40): undefined reference to的QObject :: eventFilter(的QObject *,QEvent的*)」 t_automoc.cpp :(RDATA $ _ZTV11Oefening11A [_ZTV11Oefening11A] + 0x48): 未定義參照QObject::timerEvent(QTimerEvent*)' t_automoc.cpp:(.rdata$_ZTV11Oefening11A[_ZTV11Oefening11A]+0x50): undefined reference to的QObject :: childEvent(QChildEvent *)' t_automoc.cpp :(RDATA $ _ZTV11Oefening11A [_ZTV11Oefening11A] +將0x58): 未定義參照QObject::customEvent(QEvent*)' t_automoc.cpp:(.rdata$_ZTV11Oefening11A[_ZTV11Oefening11A]+0x60): undefined reference to的QObject :: connectNotify(QMetaMethod常量&)」 t_automoc.cpp :(RDATA $ _ZTV11Oefening11A [_ZTV11Oefening11A] + 0x68)中: 未定義參照QObject::disconnectNotify(QMetaMethod const&)' t_automoc.cpp:(.rdata$_ZTV11Oefening11A[_ZTV11Oefening11A]+0x70): undefined reference to QWidget的:: DEVTYPE()const的 ' t_automoc.cpp :(RDATA $ _ZTV11Oefening11A [_ZTV11Oefening11A] + 0x78): 未定義參照QWidget::setVisible(bool)' t_automoc.cpp:(.rdata$_ZTV11Oefening11A[_ZTV11Oefening11A]+0x80): undefined reference to QWidget的:: sizeHint()const的'。 t_automoc.cpp :(RDATA $ _ZTV11Oefening11A [_ZTV11Oefening11A] + 0x88): undefined reference to QWidget::minimumSizeHint() const' t_automoc.cpp:(.rdata$_ZTV11Oefening11A[_ZTV11Oefening11A]+0x90): undefined reference to QWidget :: heightForWidth(int)const' t_automoc.cpp :(。rdata $ _ZTV11Oefening11A [_ZTV11Oefening11A] + 0x98): 未定義參照QWidget::hasHeightForWidth() const' t_automoc.cpp:(.rdata$_ZTV11Oefening11A[_ZTV11Oefening11A]+0xa0): undefined reference to QWidget的:: paintEngine()const的 ' t_automoc.cpp :(RDATA $ _ZTV11Oefening11A [_ZTV11Oefening11A] + 0xa8): 未定義參照QWidget::mousePressEvent(QMouseEvent*)' t_automoc.cpp:(.rdata$_ZTV11Oefening11A[_ZTV11Oefening11A]+0xb0): undefined reference to QWidget的:: mouseReleaseEvent(QMouseEvent *)' t_automoc.cpp :(.rdata $ _ZTV11Oefening11A [_ZTV11Oefening11A] + 0xb8): 未定義的引用QWidget::mouseDoubleClickEvent(QMouseEvent*)' t_automoc.cpp:(.rdata$_ZTV11Oefening11A[_ZTV11Oefening11A]+0xc0): undefined reference to QWidget :: mouseMoveEvent(QMouseEvent *)' t_automoc.cpp :(。RDATA $ _ZTV11Oefening11A [_ZTV11Oefening11A] + 0xc8): 未定義參照QWidget::wheelEvent(QWheelEvent*)' t_automoc.cpp:(.rdata$_ZTV11Oefening11A[_ZTV11Oefening11A]+0xd0): undefined reference to QWidget的:: keyPressEvent(QKeyEvent *)」 t_automoc.cpp :(RDATA $ _ZTV11Oefening11A [_ZTV11Oefening11A] + 0xd8): 未定義參照QWidget::keyReleaseEvent(QKeyEvent*)' t_automoc.cpp:(.rdata$_ZTV11Oefening11A[_ZTV11Oefening11A]+0xe0): undefined reference to QWidget的:: focusInEvent (QFocusEvent *) ' t_automoc.cpp :(RDATA $ _ZTV11Oefening11A [_ZTV11Oefening11A] + 0xe8): 未定義參照QWidget::focusOutEvent(QFocusEvent*)' t_automoc.cpp:(.rdata$_ZTV11Oefening11A[_ZTV11Oefening11A]+0xf0): undefined reference to QWidget的:: enterEvent(QEvent的*)'。 t_automoc.cpp :(RDATA $ _ZTV11Oefening11A [_ZTV11Oefening11A] + 0xF8的): 未定義參照QWidget::leaveEvent(QEvent*)' t_automoc.cpp:(.rdata$_ZTV11Oefening11A[_ZTV11Oefening11A]+0x100): undefined reference to QWidget的::的paintEvent(QPaintEvent *)」 t_automoc.cpp :(RDATA $ _ZTV11Oefening11A [_ZTV11Oefening11A] +量0x108): 未定義參照QWidget::moveEvent(QMoveEvent*)' t_automoc.cpp:(.rdata$_ZTV11Oefening11A[_ZTV11Oefening11A]+0x110): undefined reference to QWidget的:: 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 [_ZTV11Oefening11A] + 0×128): 未定義參照QWidget::tabletEvent(QTabletEvent*)' t_automoc.cpp:(.rdata$_ZTV11Oefening11A[_ZTV11Oefening11A]+0x130): undefined reference to QWidget的::的ActionEvent(QActionEvent *)」 t_automoc.cpp :(RDATA $ _ZTV11Oefening11A [_ZTV11Oefening11A] + 0x138): 未定義參照QWidget::dragEnterEvent(QDragEnterEvent*)' t_automoc.cpp:(.rdata$_ZTV11Oefening11A[_ZTV11Oefening11A]+0x140): undefined reference to QWidget的:: dragMoveEvent(QDragMoveEvent *) ' t_automoc.cpp :(RDATA $ _ZTV11Oefening11A [_ZTV11Oefening11A] + 0x148): 未定義參照QWidget::dragLeaveEvent(QDragLeaveEvent*)' t_automoc.cpp:(.rdata$_ZTV11Oefening11A[_ZTV11Oefening11A]+0x150): undefined reference to QWidget的:: dropEvent(QDropEvent *)'。 t_automoc.cpp :(RDATA $ _ZTV11Oefening1 1A [_ZTV11Oefening11A] + 0x158): 未定義參照QWidget::showEvent(QShowEvent*)' t_automoc.cpp:(.rdata$_ZTV11Oefening11A[_ZTV11Oefening11A]+0x160): undefined reference to QWidget的:: hideEvent(QHideEvent *)」 t_automoc.cpp :(RDATA $ _ZTV11Oefening11A [_ZTV11Oefening11A] + 0x168): 未定義參照QWidget::nativeEvent(QByteArray const&, void*, long*)' t_automoc.cpp:(.rdata$_ZTV11Oefening11A[_ZTV11Oefening11A]+0x170): undefined reference to QWidget的:: changeEvent中(QEvent的*)。 ' t_automoc.cpp :(RDATA $ _ZTV11Oefening11A [_ZTV11Oefening11A] + 0x178): 未定義參照 QWidget::metric(QPaintDevice::PaintDeviceMetric) const' t_automoc.cpp:(.rdata$_ZTV11Oefening11A[_ZTV11Oefening11A]+0x180): undefined reference to QWidget的:: initPainter(QPainter的*)const的' t_automoc.cpp :(RDATA $ _ZTV11Oefening11A [_ZTV11Oefening11A] + 0x188): 未定義的引用QWidget::redirected(QPoint*) const' t_automoc.cpp:(.rdata$_ZTV11Oefening11A[_ZTV11Oefening11A]+0x190): undefined reference to QWidget :: sharedPainter()const' t_automoc.cpp :(。rdata $ _ZTV11Oefening11A [_ZTV11Oefening11A] + 0x198): 未定義的引用QWidget::inputMethodEvent(QInputMethodEvent*)' t_automoc.cpp:(.rdata$_ZTV11Oefening11A[_ZTV11Oefening11A]+0x1a0): undefined reference to QWidget的:: inputMethodQuery(QT :: InputMethodQuery)常量 ' t_automoc.cpp :(RDATA $ _ZTV11Oefening11A [_ZTV11Oefening11A] + 0x1a8): 未定義參照QWidget::focusNextPrevChild(bool)' t_automoc.cpp:(.rdata$_ZTV11Oefening11A[_ZTV11Oefening11A]+0x1b0): undefined reference to的QMainWindow :: createPopupMenu()'。 t_automoc.cpp :(RDATA $ _ZTV11Oefening11A [_ZTV11Oefening11A] + 0x1d8): 未定義參照non-virtual thunk to QWidget::devType() const' t_automoc.cpp:(.rdata$_ZTV11Oefening11A[_ZTV11Oefening11A]+0x1e0): undefined reference to非虛擬形實轉換到QWidget的:: paintEngine() 常量」 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非虛擬thunk到 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非虛形實轉換到了QWidget :: sharedPainter()const的 」

找不到我的cmake文件中的問題。有人可以幫我弄這個嗎?

+0

您的CMakeLists.txt對我來說看起來很好。 'CMAKE_AUTOUIC'不是必需的。如果文件的名稱爲'ui_oefening11a.h',我會查看構建目錄。 – oLen

回答

0

此外moc,你將需要運行uic還有:

set(CMAKE_AUTOUIC ON) 
+0

當我添加這個時,我得到了錯誤的未定義引用的分配。 – JimmyD

+0

究竟是什麼錯誤? –

+0

在問題中添加了確切的錯誤。 – JimmyD

0

好吧,我發現這個問題。我在x86 QT5庫上使用了x64編譯器。將編譯器更改爲x86編譯器時,它會進行編譯。