<div dir="ltr">Hello everyone!<br><br>I'm trying to compile a simple application using Qt4 with cmake, but I'm stucked in this error:<br><br>[ 33%] Generating ui_mivgui.h<br>Scanning dependencies of target viewer<br>
[ 66%] Building CXX object CMakeFiles/viewer.dir/main.o<br>[100%] Building CXX object CMakeFiles/viewer.dir/mivgui.o<br>Linking CXX executable viewer<br>CMakeFiles/viewer.dir/mivgui.o: In function `MivGui::MivGui(QWidget*)':<br>
mivgui.cxx:(.text+0x14e): undefined reference to `vtable for MivGui'<br>mivgui.cxx:(.text+0x158): undefined reference to `vtable for MivGui'<br>CMakeFiles/viewer.dir/mivgui.o: In function `MivGui::MivGui(QWidget*)':<br>
mivgui.cxx:(.text+0x2c6): undefined reference to `vtable for MivGui'<br>mivgui.cxx:(.text+0x2d0): undefined reference to `vtable for MivGui'<br>CMakeFiles/viewer.dir/mivgui.o: In function `MivGui::tr(char const*, char const*)':<br>
mivgui.cxx:(.text._ZN6MivGui2trEPKcS1_[MivGui::tr(char const*, char const*)]+0x1e): undefined reference to `MivGui::staticMetaObject'<br>collect2: ld returned 1 exit status<br>make[2]: *** [viewer] Error 1<br>make[1]: *** [CMakeFiles/viewer.dir/all] Error 2<br>
make: *** [all] Error 2<br><br>This is the code I have for mivgui.h:<br><br>#include "ui_mivgui.h"<br><br>class MivGui : public QMainWindow, private Ui::MivGui<br>{<br> Q_OBJECT<br><br> public:<br> MivGui(QWidget *parent = 0);<br>
<br> private slots:<br> void open();<br>};<br><br>And for the mivgui.cxx:<br><br>#include <QtGui><br>#include "mivgui.h"<br><br>MivGui::MivGui(QWidget *parent): QMainWindow(parent)<br>{<br> setupUi(this);<br>
<br> QDesktopWidget *desktop = QApplication::desktop();<br> <br> int screenWidth, width; <br> int screenHeight, height;<br> int x, y;<br> QSize windowSize;<br> <br> screenWidth = desktop->width(); // get width of screen<br>
screenHeight = desktop->height(); // get height of screen<br> <br> windowSize = size(); // size of our application window<br> width = windowSize.width(); <br> height = windowSize.height();<br> <br> // little computations<br>
x = (screenWidth - width) / 2;<br> y = (screenHeight - height) / 2;<br> y -= 50;<br> <br> // move window to desired coordinates<br> move ( x, y );<br><br> // make connections<br> connect(actionOpen, SIGNAL(triggered()), this, SLOT(open()));<br>
}<br><br>void MivGui::open()<br>{<br> QString fileName = QFileDialog::getOpenFileName(this, tr("Open File"), QDir::currentPath());<br>}<br><br><br>CMakeLists.txt<br>----------------------------------------------------------------------------------------------------------------------------------------------<br>
<br>SET(SOURCES_CPP<br> main.cxx<br> mivgui.cxx)<br>MESSAGE( STATUS ${SOURCES_CPP} )<br><br>SET(SOURCES_H<br> mivgui.h)<br>MESSAGE( STATUS ${SOURCES_H} )<br><br>SET(SOURCES_UI<br> mivgui.ui)<br>MESSAGE( STATUS ${SOURCES_UI} )<br>
<br>FIND_PACKAGE(Qt4 REQUIRED)<br><br>include(${QT_USE_FILE})<br><br>QT4_WRAP_UI(SOURCES_UI_H ${SOURCES_UI})<br><br>#qt4_automoc(${SOURCES_H})<br><br>INCLUDE_DIRECTORIES( ${CMAKE_CURRENT_BINARY_DIR} )<br><br>ADD_EXECUTABLE(viewer ${SOURCES_CPP} ${SOURCES_H} ${SOURCES_UI_H})<br>
<br>TARGET_LINK_LIBRARIES(viewer ${QT_LIBRARIES} ${QT_QTSQL_LIBRARIES})<br><br>----------------------------------------------------------------------------------------------------------------------------------------------<br>
<br>Does anybody know how to solve this problem?<br><br>PS: It works fine with qmake, but I need to use cmake in order to integrate with some ITK functions.<br><br>Thanks,<br>Luis<br></div>