2017-04-20 3 views
0

nicht finden Ich erstelle ein Cmake-Projekt meiner Qt5-Anwendung. Jetzt, als ich meine Anwendung mit cmake in Clion kompiliere, habe ich einen fatalen Fehler bekommen.Qt5 cmake kann Header-Datei von ui

Meine CMakeLists.txt Datei wie folgt aussieht:

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) 

Der Fehler, dass Clion trowing wird, wenn ich die Anwendung zu kompilieren ist:

oefening11a.cpp: 21: undefined reference to __imp__ZN8QtCharts11QLineSeriesC1EP7QObject' oefening11a.cpp:26: undefined reference to __imp__ZN8QtCharts9QXYSeries6appendEdd ' oefening11a.cpp: 30: undefinierter Verweis auf __imp__ZN8QtCharts6QChartC1EP13QGraphicsItem6QFlagsIN2Qt10WindowTypeEE' oefening11a.cpp:31: undefined reference to __imp__ZN8QtCharts6QChart9addSeriesEPNS_15QAbstract SeriesE ' oefening11a.cpp: 32: undefiniert Bezug auf __imp__ZNK8QtCharts6QChart6legendEv' oefening11a.cpp:33: undefined reference to __imp__ZN8QtCharts6QChart8setTitleERK7QString' oefening11a.cpp: 36: undefiniert Bezug auf __imp__ZN8QtCharts10QValueAxisC1EP7QObject' oefening11a.cpp:37: undefined reference to __imp__ZN8QtCharts10QValueAxis14setLabelFormatERK7QString ' oefening11a.cpp: 38: undefiniert Bezug auf __imp__ZN8QtCharts13QAbstractAxis12setTitleTextERK7QString' oefening11a.cpp:39: undefined reference to __imp__ZN8QtCharts6QChart7addAxisEPNS_13QAbstractAxisE6QFlagsIN2Qt13AlignmentFlagEE' oefening11a.cpp: 40 : undefined Bezug auf __imp__ZN8QtCharts15QAbstractSeries10attachAxisEPNS_13QAbstractAxisE' oefening11a.cpp:43: undefined reference to __imp__ZN8QtCharts10QValueAxisC1EP7QObject 'oefening11a.cpp: 44: undefinierten Bezug auf __imp__ZN8QtCharts10QValueAxis14setLabelFormatERK7QString' oefening11a.cpp:45: undefined reference to __imp__ZN8QtCharts13QAbstractAxis12setTitleTextERK7QString' oefening11a.cpp: 46: undefiniert Bezug auf __imp__ZN8QtCharts6QChart7addAxisEPNS_13QAbstractAxisE6QFlagsIN2Qt13AlignmentFlagEE' oefening11a.cpp:47: undefined reference to __imp__ZN8QtCharts15QAbstractSeries10attachAxisEPNS_13QAbstractAxisE ' oefening11a.cpp: 50: undefiniert Bezug auf __imp__ZN8QtCharts10QChartViewC1EPNS_6QChartEP7QWidget' oefening11a.cpp:51: undefined reference to __imp__ZN13QGraphicsView13setRenderHintEN8QPainter10RenderHintEb' oefening11a.cpp: 54: undefiniert Bezug auf __imp__ZN11QMainWindow16setCentralWidgetEP7QWidget' oefening11a.cpp:73: undefined reference to __imp__ZN10QStatusBar11showMessageERK7QStringi‘t_automoc.cpp :(RDATA $. _ZTV11Oefening11A [_ZTV11Oefening11A] + 0x38): undefined reference to QMainWindow::event(QEvent*)' t_automoc.cpp:(.rdata$_ZTV11Oefening11A[_ZTV11Oefening11A]+0x40): undefined reference to QObject :: event (QObject *, QEvent *)‘ t_automoc.cpp :(rdata $ _ZTV11Oefening11A [_ZTV11Oefening11A] + 0x48):. undefined reference to QObject::timerEvent(QTimerEvent*)' t_automoc.cpp:(.rdata$_ZTV11Oefening11A[_ZTV11Oefening11A]+0x50): undefined reference to QObject :: childEvent (QChildEvent *) ' t_automoc.cpp :(rdata $ _ZTV11Oefening11A [_ZTV11Oefening11A] + 0x58):. undefined reference to QObject::customEvent(QEvent*)' t_automoc.cpp:(.rdata$_ZTV11Oefening11A[_ZTV11Oefening11A]+0x60): undefined reference to QObject :: connectNotify (QMetaMethod const &)‘ t_automoc.cpp :(rdata $ _ZTV11Oefening11A [_ZTV11Oefening11A] + 0x68). undefined reference to QObject::disconnectNotify(QMetaMethod const&)' t_automoc.cpp:(.rdata$_ZTV11Oefening11A[_ZTV11Oefening11A]+0x70): undefined reference to QWidget :: DEVTYPE() const ' t_automoc.cpp :(rdata $ _ZTV11Oefening11A [_ZTV11Oefening11A] + 0x78):. undefined reference to 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):. undefined reference to QWidget::hasHeightForWidth() const' t_automoc.cpp:(.rdata$_ZTV11Oefening11A[_ZTV11Oefening11A]+0xa0): undefined reference to QWidget :: paintEngine() const ' t_automoc.cpp :(rdata $ _ZTV11Oefening11A [_ZTV11Oefening11A] + 0xa8.): undefined reference to QWidget::mousePressEvent(QMouseEvent*)' t_automoc.cpp:(.rdata$_ZTV11Oefening11A[_ZTV11Oefening11A]+0xb0): undefined reference to QWidget :: mouse (QMouseEvent *)' t_automoc.cpp :(.data $ _ZTV11Oefening11A [_ZTV11Oefening11A] + 0xb8): undefinierter Verweis auf QWidget::mouseDoubleClickEvent(QMouseEvent*)' t_automoc.cpp:(.rdata$_ZTV11Oefening11A[_ZTV11Oefening11A]+0xc0): undefined reference to QWidget :: mouseMoveEvent (QMouseEvent *) ' t_automoc.cpp :(.rdata $ _ZTV11Oefening11A [_ZTV11Oefening11A] + 0xC8): undefined reference to QWidget::wheelEvent(QWheelEvent*)' t_automoc.cpp:(.rdata$_ZTV11Oefening11A[_ZTV11Oefening11A]+0xd0): undefined reference to QWidget :: keyPressEvent (QKeyEvent *)‘ t_automoc.cpp :(rdata $ _ZTV11Oefening11A [_ZTV11Oefening11A] + 0xd8.): undefined reference to QWidget::keyReleaseEvent(QKeyEvent*)' t_automoc.cpp:(.rdata$_ZTV11Oefening11A[_ZTV11Oefening11A]+0xe0): undefined reference to QWidget :: focusInEvent (QFocusEvent *) ' t_automoc.cpp :(rdata $ _ZTV11Oefening11A [_ZTV11Oefening11A] + 0xE8):. undefined reference to QWidget::focusOutEvent(QFocusEvent*)' t_automoc.cpp:(.rdata$_ZTV11Oefening11A[_ZTV11Oefening11A]+0xf0): undefined reference to QWidget :: enterEvent (QEvent *)'. t_automoc.cpp :(rdata $ _ZTV11Oefening11A [_ZTV11Oefening11A] + 0xF8): undefined reference to QWidget::leaveEvent(QEvent*)' t_automoc.cpp:(.rdata$_ZTV11Oefening11A[_ZTV11Oefening11A]+0x100): undefined reference to QWidget :: paintEventO (QPaintEvent *)‘ t_automoc.cpp :(rdata $ _ZTV11Oefening11A [_ZTV11Oefening11A] + 0x108). undefined reference to QWidget::moveEvent(QMoveEvent*)' t_automoc.cpp:(.rdata$_ZTV11Oefening11A[_ZTV11Oefening11A]+0x110): undefined reference to QWidget :: resizeEvent (QResizeEvent *) ' t_automoc.cpp :(rdata $ _ZTV11Oefening11A [_ZTV11Oefening11A] + 0x118). undefined reference to QWidget::closeEvent(QCloseEvent*)' t_automoc.cpp:(.rdata$_ZTV11Oefening11A[_ZTV11Oefening11A]+0x120): undefined reference to QMainWindow :: contextMenuEvent (QContextMenuEvent *)'. t_automoc.cpp :(rdata $ _ZTV11Oefening11A [_ZTV11Oefening11A] + 0x128): undefined reference to QWidget::tabletEvent(QTabletEvent*)' t_automoc.cpp:(.rdata$_ZTV11Oefening11A[_ZTV11Oefening11A]+0x130): undefined reference to QWidget :: Action (QActionEvent *)‘ t_automoc.cpp :(rdata $ _ZTV11Oefening11A [_ZTV11Oefening11A] + 0x138). undefined reference to QWidget::dragEnterEvent(QDragEnterEvent*)' t_automoc.cpp:(.rdata$_ZTV11Oefening11A[_ZTV11Oefening11A]+0x140): undefined reference to QWidget :: dragMoveEvent (QDragMoveEvent *) ' t_automoc.cpp :(rdata $ _ZTV11Oefening11A [_ZTV11Oefening11A] + 0x148). undefined reference to QWidget::dragLeaveEvent(QDragLeaveEvent*)' t_automoc.cpp:(.rdata$_ZTV11Oefening11A[_ZTV11Oefening11A]+0x150): undefined reference to QWidget :: dropEvent (QDropEvent *)'. t_automoc.cpp :(rdata $ _ZTV11Oefening1 1A [_ZTV11Oefening11A] + 0x158): undefined reference to QWidget::showEvent(QShowEvent*)' t_automoc.cpp:(.rdata$_ZTV11Oefening11A[_ZTV11Oefening11A]+0x160): undefined reference to QWidget :: hideEvent (QHideEvent *)‘ t_automoc.cpp :(rdata $ _ZTV11Oefening11A [_ZTV11Oefening11A] + 0x168). undefined reference to QWidget::nativeEvent(QByteArray const&, void*, long*)' t_automoc.cpp:(.rdata$_ZTV11Oefening11A[_ZTV11Oefening11A]+0x170): undefined reference to QWidget :: change (QEvent *). ' t_automoc.cpp :(rdata $ _ZTV11Oefening11A [_ZTV11Oefening11A] + 0x178). undefined reference to 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): undefined Verweis auf QWidget::redirected(QPoint*) const' t_automoc.cpp:(.rdata$_ZTV11Oefening11A[_ZTV11Oefening11A]+0x190): undefined reference to QWidget :: sharedPainter() const ' t_automoc.cpp :(.RData $ _ZTV11Oefening11A [_ZTV11Oefening11A] + 0x198): undefined Verweis auf QWidget::inputMethodEvent(QInputMethodEvent*)' t_automoc.cpp:(.rdata$_ZTV11Oefening11A[_ZTV11Oefening11A]+0x1a0): undefined reference to QWidget :: inputMethodQuery (Qt :: InputMethodQuery) const ' t_automoc.cpp :(rdata $ _ZTV11Oefening11A [_ZTV11Oefening11A] + 0x1a8.): undefined reference to QWidget::focusNextPrevChild(bool)' t_automoc.cpp:(.rdata$_ZTV11Oefening11A[_ZTV11Oefening11A]+0x1b0): undefined reference to QMainWindow :: CreatePopupMenu()'. t_automoc.cpp :(rdata $ _ZTV11Oefening11A [_ZTV11Oefening11A] + 0x1d8): undefined Verweis auf non-virtual thunk to QWidget::devType() const' t_automoc.cpp:(.rdata$_ZTV11Oefening11A[_ZTV11Oefening11A]+0x1e0): undefined reference to nicht-virtuellen Thunk zu QWidget :: paintEngine() const‘ t_automoc.cpp :(rdata $ _ZTV11Oefening11A [_ZTV11Oefening11A] + 0x1e8.): undefined reference to non-virtual thunk to QWidget::metric(QPaintDevice::PaintDeviceMetric) const' t_automoc.cpp:(.rdata$_ZTV11Oefening11A[_ZTV11Oefening11A]+0x1f0): undefined reference to nicht virtueller Thunk zu QWidget :: initPainter (QPainter *) const ' t_automoc.cpp :(.RData $ _ZTV11Oefening11A [_ZTV11Oefening11A] + 0x1f8): undefined Verweis auf non-virtual thunk to QWidget::redirected(QPoint*) const' t_automoc.cpp:(.rdata$_ZTV11Oefening11A[_ZTV11Oefening11A]+0x200): undefined reference to nicht-virtuellen Thunk zu QWidget :: sharedPainter() const‘

Kann das Problem nicht in meiner cmake-Datei. Kann mir jemand dabei helfen?

+0

Ihre CMakeLists.txt sieht gut aus für mich. 'CMAKE_AUTOUIC' ist nicht notwendig. Ich würde in das Build-Verzeichnis schauen, wenn die Datei wirklich den Namen 'ui_oefening11a.h' hat. – oLen

Antwort

0

Neben moc, müssen Sie uic auch auszuführen:

set(CMAKE_AUTOUIC ON) 
+0

Wenn ich das hinzufüge, habe ich einen unbestimmten Verweis auf Fehler. – JimmyD

+0

Welche Fehler genau? –

+0

Der genaue Fehler zur Frage hinzugefügt. – JimmyD

0

Ok fand ich das Problem. Ich benutzte einen x64-Compiler für x86-QT5-Bibliotheken. Wenn der Compiler in einen x86-Code geändert wird, wird er kompiliert.

Verwandte Themen