[Insight-users] Qt with Cmake linking problem
Mike Jackson
imikejackson at gmail.com
Wed Mar 7 08:59:50 EST 2007
I have a Qt/ITK app that compiles fine. Here are the differences:
In your file you have the following:
qt4_automoc(${SOURCES_H})
I have:
QT4_WRAP_CPP( MOC_SOURCES ${SOURCES_H} )
I also have:
#-- Add the Defs for Qt.
ADD_DEFINITIONS(-DQT_GUI_LIBS -DQT_CORE_LIB)
SET_SOURCE_FILES_PROPERTIES(${QSERIES_TO_VOLUME_QT_SRCS} PROPERTIES
OBJECT_DEPENDS "${QSERIES_TO_VOLUME_UI_HDRS}")
IF(WIN32)
SET(GUI_TYPE WIN32)
ADD_DEFINITIONS(-DNODEFAULTLIB:library)
SET (${QT_LIBRARIES} qtmain ${QT_LIBRARIES})
ENDIF(WIN32)
Some of this is out of context. If you want my entire CMakeLists.txt
file let me know.
--
Mike Jackson Senior Research Engineer
Innovative Management & Technology Services
On Mar 7, 2007, at 7:24 AM, Nicolas wrote:
> Hello everybody,
> I'm actually trying to compile a QT application using a .ui with
> Cmake. The application works using qmake but I have to use CMake
> beause I'm using ITK too.
> I still have problems with the linking phase (error listed below).
> Does anyone have an idea what is missing in my CmakeLists.txt ?
> Thanks a lot in advance ! nico
> ___________________________________________
> PROJECT(browserPileImagesStandalone)
> cmake_minimum_required(VERSION 2.4.0)
>
> #IF( BUILD_OUTSIDE_INSIGHT_APPLICATIONS )
> FIND_PACKAGE(ITK REQUIRED)
> IF(ITK_FOUND)
> INCLUDE(${ITK_USE_FILE})
> ELSE(ITK_FOUND)
> MESSAGE(FATAL_ERROR
> "Cannot build InsightApplications without ITK. Please
> set ITK_DIR.")
> ENDIF(ITK_FOUND)
> #ENDIF( BUILD_OUTSIDE_INSIGHT_APPLICATIONS )
>
> SET(SOURCES_CPP
> ../code/main.cpp
> ../code/browserPileImages.cpp)
> MESSAGE( STATUS ${SOURCES_CPP} )
>
> SET(SOURCES_H
> ../code/browserPileImages.h)
> MESSAGE( STATUS ${SOURCES_H} )
>
> SET(SOURCES_UI
> ../code/browserPileImages.ui)
> MESSAGE( STATUS ${SOURCES_UI} )
>
> # Find QT4
> # attention a la casse de Qt4 !!
> FIND_PACKAGE(Qt4 REQUIRED)
>
> include(${QT_USE_FILE})
>
> # execute uic sur les fichier .ui -> generation des .h associes
> # ne pas oublier de rajouter les .h generes a add_exectuable
> QT4_WRAP_UI(SOURCES_UI_H ${SOURCES_UI})
>
> # pour la macro Q_OBJECT..
> qt4_automoc(${SOURCES_H})
>
> # pour trouver le ui_h
> INCLUDE_DIRECTORIES( ${CMAKE_CURRENT_BINARY_DIR} )
>
> ADD_EXECUTABLE(browserPileImagesStandalone ${SOURCES_CPP} $
> {SOURCES_H} ${SOURCES_UI_H})
>
> TARGET_LINK_LIBRARIES(browserPileImagesStandalone ${QT_LIBRARIES} )
> ___________________________________________
>
> browserPileImages.obj : error LNK2019: unresolved external symbol
> "public: static struct QMetaObject const
> BrowserPileImages::staticMetaObject" (?
> staticMetaObject at BrowserPileImages@@2UQMetaObject@@B) referenced in
> function "public: static class QString __cdecl BrowserPileImages::tr
> (char const *,char const *)" (?tr at BrowserPileImages@@SA?
> AVQString@@PEBD0 at Z)
> 1>browserPileImages.obj : error LNK2001: unresolved external symbol
> "public: virtual struct QMetaObject const * __cdecl
> BrowserPileImages::metaObject(void)const " (?
> metaObject at BrowserPileImages@@UEBAPEBUQMetaObject@@XZ)
>
> 1>browserPileImages.obj : error LNK2001: unresolved external symbol
> "public: virtual void * __cdecl BrowserPileImages::qt_metacast(char
> const *)" (?qt_metacast at BrowserPileImages@@UEAAPEAXPEBD at Z)
>
> 1>browserPileImages.obj : error LNK2001: unresolved external symbol
> "public: virtual int __cdecl BrowserPileImages::qt_metacall(enum
> QMetaObject::Call,int,void * *)" (?
> qt_metacall at BrowserPileImages@@UEAAHW4Call at QMetaObject@@HPEAPEAX at Z)
>
> 1>Release\browserPileImagesStandalone.exe : fatal error LNK1120: 4
> unresolved externals
>
>
>
> --
> Nicolas FETE, PhD student biotech
> EPFL Computer Science Engineer
> Ecole Polytechnique Federale de Lausanne
> Faculte des Sciences de la Vie
> Laboratoire de Dynamique des Cellules Souches
> Batiment AAB
> Station 15
> CH-1015 Lausanne
> Tel:+41 21 693 16 33
> Fax:+41 21 693 16 30
> HomePage (under construction): http://ldcs.epfl.ch
> _______________________________________________
> Insight-users mailing list
> Insight-users at itk.org
> http://www.itk.org/mailman/listinfo/insight-users
More information about the Insight-users
mailing list