<div dir="ltr">Thanks for your help Christian, but I just solved the problem with the
following CMakeLists.txt file. In this solution I don&#39;t need to add&nbsp;
#include &quot;mivgui.moc&quot; at the end of file.<br><br><br>
CMakeLists.txt<br>------------------------------------------------------------------------------------------------------------------------------------------------------------<br><div dir="ltr"># set project&#39;s name<br>
PROJECT( sample )<br>
<br># with SET() command you can change variables or define new ones<br># here we define SAMPLE_SRCS variable that contains a list of all .cpp files<br># note that we don&#39;t need \ at the end of line<br>SET( SAMPLE_SRCS<br>

./mivgui.cxx<br>./main.cxx<br>)<br><br># another list, this time it includes all header files that should be treated with moc<br>SET( SAMPLE_MOC_HDRS<br>./mivgui.h<br>)<br><br># some .ui files<br>SET( SAMPLE_UIS<br>./mivgui.ui<br>

)<br><br># enable warnings<br>ADD_DEFINITIONS( -Wall )<br><br># by default only QtCore and QtGui modules are enabled<br># other modules must be enabled like this:<br>SET( QT_USE_QT3SUPPORT TRUE )<br>SET( QT_USE_QTXML TRUE )<br>

<br># this command finds Qt4 libraries and sets all required variables<br># note that it&#39;s Qt4, not QT4 or qt4<br>FIND_PACKAGE( Qt4 REQUIRED )<br><br># add some useful macros and variables<br># (QT_USE_FILE is a variable defined by FIND_PACKAGE( Qt4 ) that contains a path to CMake script)<br>

INCLUDE( ${QT_USE_FILE} )<br><br># this will run uic on .ui files:<br>QT4_WRAP_UI( SAMPLE_UI_HDRS ${SAMPLE_UIS} )<br><br># and finally this will run moc:<br>QT4_WRAP_CPP( SAMPLE_MOC_SRCS ${SAMPLE_MOC_HDRS} )<br><br># we need this to be able to include headers produced by uic in our code<br>

# (CMAKE_BINARY_DIR holds a path to the build directory, while INCLUDE_DIRECTORIES() works just like INCLUDEPATH from qmake)<br>INCLUDE_DIRECTORIES( ${CMAKE_BINARY_DIR} )<br><br># here we instruct CMake to build &quot;sample&quot; executable from all of the source files<br>

ADD_EXECUTABLE( sample ${SAMPLE_SRCS} ${SAMPLE_MOC_SRCS} ${SAMPLE_UI_HDRS} )<br><br># last thing we have to do is to tell CMake what libraries our executable needs,<br># luckily FIND_PACKAGE prepared QT_LIBRARIES variable for us:<br>

TARGET_LINK_LIBRARIES( sample ${QT_LIBRARIES} )<br><br>------------------------------------------------------------------------------------------------------------------------------------------------------------</div><br>
<br><div class="gmail_quote">On Tue, Sep 9, 2008 at 3:35 AM, Luis Roberto P. Paula <span dir="ltr">&lt;<a href="mailto:luisrpp@gmail.com">luisrpp@gmail.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div dir="ltr">Oh... I left it commented just for testing. Wrong copy-paste... sorry.<br><br>But even if this line is not commented, the same error message is displayed.<div><div></div><div class="Wj3C7c"><br><br><div class="gmail_quote">
On Tue, Sep 9, 2008 at 3:26 AM, Christian Ehrlicher <span dir="ltr">&lt;<a href="mailto:Ch.Ehrlicher@gmx.de" target="_blank">Ch.Ehrlicher@gmx.de</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">&gt; Von: &quot;Luis Roberto P. Paula&quot;<br>
<div>&gt; Hello everyone!<br>
&gt;<br>
&gt; I&#39;m trying to compile a simple application using Qt4 with cmake, but I&#39;m<br>
&gt; stucked in this error:<br>
&gt;<br>
&gt; [ 33%] Generating ui_mivgui.h<br>
&gt; Scanning dependencies of target viewer<br>
&gt; [ 66%] Building CXX object CMakeFiles/viewer.dir/main.o<br>
&gt; [100%] Building CXX object CMakeFiles/viewer.dir/mivgui.o<br>
&gt; Linking CXX executable viewer<br>
&gt; CMakeFiles/viewer.dir/mivgui.o: In function `MivGui::MivGui(QWidget*)&#39;:<br>
&gt; mivgui.cxx:(.text+0x14e): undefined reference to `vtable for MivGui&#39;<br>
&gt; mivgui.cxx:(.text+0x158): undefined reference to `vtable for MivGui&#39;<br>
&gt; CMakeFiles/viewer.dir/mivgui.o: In function `MivGui::MivGui(QWidget*)&#39;:<br>
&gt; mivgui.cxx:(.text+0x2c6): undefined reference to `vtable for MivGui&#39;<br>
&gt; mivgui.cxx:(.text+0x2d0): undefined reference to `vtable for MivGui&#39;<br>
&gt; CMakeFiles/viewer.dir/mivgui.o: In function `MivGui::tr(char const*, char<br>
&gt; const*)&#39;:<br>
&gt; mivgui.cxx:(.text._ZN6MivGui2trEPKcS1_[MivGui::tr(char const*, char<br>
&gt; const*)]+0x1e): undefined reference to `MivGui::staticMetaObject&#39;<br>
&gt; collect2: ld returned 1 exit status<br>
&gt; make[2]: *** [viewer] Error 1<br>
&gt; make[1]: *** [CMakeFiles/viewer.dir/all] Error 2<br>
&gt; make: *** [all] Error 2<br>
&gt;<br>
</div>&lt;snip&gt;<br>
<div>&gt;<br>
&gt; CMakeLists.txt<br>
&gt; ----------------------------------------------------------------------------------------------------------------------------------------------<br>
&gt;<br>
&gt; SET(SOURCES_CPP<br>
&gt; &nbsp;main.cxx<br>
&gt; &nbsp;mivgui.cxx)<br>
&gt; MESSAGE( STATUS ${SOURCES_CPP} )<br>
&gt;<br>
&gt; SET(SOURCES_H<br>
&gt; &nbsp;mivgui.h)<br>
&gt; MESSAGE( STATUS ${SOURCES_H} )<br>
&gt;<br>
&gt; SET(SOURCES_UI<br>
&gt; &nbsp;mivgui.ui)<br>
&gt; MESSAGE( STATUS ${SOURCES_UI} )<br>
&gt;<br>
&gt; FIND_PACKAGE(Qt4 REQUIRED)<br>
&gt;<br>
&gt; include(${QT_USE_FILE})<br>
&gt;<br>
&gt; QT4_WRAP_UI(SOURCES_UI_H ${SOURCES_UI})<br>
&gt;<br>
&gt; #qt4_automoc(${SOURCES_H})<br>
&gt;<br>
</div>Why did you comment out this line?<br>
You need to moc your header - otherwise you&#39;ll get linker errors like above.<br>
<br>
<br>
Christian<br>
<font color="#888888">--<br>
GMX startet ShortView.de. Hier findest Du Leute mit Deinen Interessen!<br>
Jetzt dabei sein: <a href="http://www.shortview.de/wasistshortview.php?mc=sv_ext_mf@gmx" target="_blank">http://www.shortview.de/wasistshortview.php?mc=sv_ext_mf@gmx</a><br>
_______________________________________________<br>
CMake mailing list<br>
<a href="mailto:CMake@cmake.org" target="_blank">CMake@cmake.org</a><br>
<a href="http://www.cmake.org/mailman/listinfo/cmake" target="_blank">http://www.cmake.org/mailman/listinfo/cmake</a><br>
</font></blockquote></div><br></div></div></div>
</blockquote></div><br></div>