[CMake] Re: cmake linking problem
Hi Thank you all, problem solved, off course it was a case of RTFM... I have just left out the generating of the moc files Thanks best regards Anders On 7/13/07, Anders Sandholm [EMAIL PROTECTED] wrote: Hi Using Cmake (vtk) with QT and trying to build using visual studio 2005. Now I have compiled both vtk and QT with visual studio 2005, and simple QT applications (like hello world workes perfekt) but now I try to do some a little more advanced and I get a linking problem. The source code that I try to compile is the Sliders Example (http://doc.trolltech.com/4.0/widgets-sliders.html) (the HelloWorld example I can compile with cmake) Now I am new to CMake, but the CMake file I am using look like: PROJECT (Test) FIND_PACKAGE(VTK REQUIRED) find_package(Qt4 REQUIRED) IF(NOT VTK_USE_RENDERING) MESSAGE(FATAL_ERROR Example ${PROJECT_NAME} requires VTK_USE_RENDERING.) ENDIF(NOT VTK_USE_RENDERING) INCLUDE(${VTK_USE_FILE}) include(${QT_USE_FILE}) # the next line sets up include and link directories and defines some variables that we will use. # you can modify the behavior by setting some variables, e.g. # set(QT_USE_OPENGL TRUE) # - this will cause cmake to include and link against the OpenGL module include(${QT_USE_FILE}) # the variable qtproject_SRCS contains all .cpp files of this project set(qtproject_SRCS main.cpp window.h window.cpp slidersgroup.h slidersgroup.cpp ) INCLUDE_DIRECTORIES(qtproject_SRCS ${QT_INCLUDE_DIR} ${QT_QTNETWORK_INCLUDE_DIR} ${QT_QTTEST_INCLUDE_DIR} ) link_directories(qtproject_srcs ${QT_LIBRARIES} ${QT_QTNETWORK_LIBRARIES} ${QT_QTTEST_LIBRARIES} ) # tell cmake to create .moc files for all files in the variable qtproject_SRCS that require such a file. # note: this assumes that you use #include header.moc in your files qt4_automoc(${qtproject_SRCS}) # create an executable file named qtproject from the source files in the variable qtproject_SRCS. add_executable(qtproject ${qtproject_SRCS}) TARGET_LINK_LIBRARIES(qtproject ${QT_LIBRARIES} ${QT_QTNETWORK_LIBRARIES} ${QT_QTTEST_LIBRARIES} ) Now when I build in vs2005 it says: 1-- Build started: Project: qtproject, Configuration: Release Win32 -- 1Linking... 1window.obj : error LNK2019: unresolved external symbol public: static struct QMetaObject const Window::staticMetaObject ([EMAIL PROTECTED]@@2UQMetaObject@@B) referenced in function public: static class QString __cdecl Window::tr(char const *,char const *) ([EMAIL PROTECTED]@@SA?AVQString@@[EMAIL PROTECTED]) 1window.obj : error LNK2001: unresolved external symbol public: virtual struct QMetaObject const * __thiscall Window::metaObject(void)const ([EMAIL PROTECTED]@@UBEPBUQMetaObject@@XZ) 1window.obj : error LNK2001: unresolved external symbol public: virtual void * __thiscall Window::qt_metacast(char const *) ([EMAIL PROTECTED]@@[EMAIL PROTECTED]) 1window.obj : error LNK2001: unresolved external symbol public: virtual int __thiscall Window::qt_metacall(enum QMetaObject::Call,int,void * *) ([EMAIL PROTECTED]@@[EMAIL PROTECTED]@@[EMAIL PROTECTED]) 1slidersgroup.obj : error LNK2001: unresolved external symbol public: virtual struct QMetaObject const * __thiscall SlidersGroup::metaObject(void)const ([EMAIL PROTECTED]@@UBEPBUQMetaObject@@XZ) 1slidersgroup.obj : error LNK2001: unresolved external symbol public: virtual void * __thiscall SlidersGroup::qt_metacast(char const *) ([EMAIL PROTECTED]@@[EMAIL PROTECTED]) 1slidersgroup.obj : error LNK2001: unresolved external symbol public: virtual int __thiscall SlidersGroup::qt_metacall(enum QMetaObject::Call,int,void * *) ([EMAIL PROTECTED]@@[EMAIL PROTECTED]@@[EMAIL PROTECTED]) 1Release\qtproject.exe : fatal error LNK1120: 7 unresolved externals 1Build log was saved at file://z:\temp2\qtproject.dir\Release\BuildLog.htm 1qtproject - 8 error(s), 0 warning(s) == Build: 0 succeeded, 1 failed, 1 up-to-date, 0 skipped == The BuildLog.htm says Build Log Build started: Project: qtproject, Configuration: Release|Win32 Command Lines Creating temporary file z:\temp2\qtproject.dir\Release\RSP0136204020.rsp with contents [ /OUT:Release\qtproject.exe /VERSION:0.0 /INCREMENTAL:NO /LIBPATH:c:\vtkBin\bin\Release /LIBPATH:c:\vtkBin\bin /LIBPATH:qtproject_srcs\Release /LIBPATH:qtproject_srcs /LIBPATH:optimized\Release /LIBPATH:optimized /LIBPATH:c:\QT\lib\QtGui4.lib\Release /LIBPATH:c:\QT\lib\QtGui4.lib /LIBPATH:debug\Release /LIBPATH:debug /LIBPATH:c:\QT\lib\QtGuid4.lib\Release /LIBPATH:c:\QT\lib
[CMake] cmake linking problem
Hi Using Cmake (vtk) with QT and trying to build using visual studio 2005. Now I have compiled both vtk and QT with visual studio 2005, and simple QT applications (like hello world workes perfekt) but now I try to do some a little more advanced and I get a linking problem. The source code that I try to compile is the Sliders Example (http://doc.trolltech.com/4.0/widgets-sliders.html) (the HelloWorld example I can compile with cmake) Now I am new to CMake, but the CMake file I am using look like: PROJECT (Test) FIND_PACKAGE(VTK REQUIRED) find_package(Qt4 REQUIRED) IF(NOT VTK_USE_RENDERING) MESSAGE(FATAL_ERROR Example ${PROJECT_NAME} requires VTK_USE_RENDERING.) ENDIF(NOT VTK_USE_RENDERING) INCLUDE(${VTK_USE_FILE}) include(${QT_USE_FILE}) # the next line sets up include and link directories and defines some variables that we will use. # you can modify the behavior by setting some variables, e.g. # set(QT_USE_OPENGL TRUE) # - this will cause cmake to include and link against the OpenGL module include(${QT_USE_FILE}) # the variable qtproject_SRCS contains all .cpp files of this project set(qtproject_SRCS main.cpp window.h window.cpp slidersgroup.h slidersgroup.cpp ) INCLUDE_DIRECTORIES(qtproject_SRCS ${QT_INCLUDE_DIR} ${QT_QTNETWORK_INCLUDE_DIR} ${QT_QTTEST_INCLUDE_DIR} ) link_directories(qtproject_srcs ${QT_LIBRARIES} ${QT_QTNETWORK_LIBRARIES} ${QT_QTTEST_LIBRARIES} ) # tell cmake to create .moc files for all files in the variable qtproject_SRCS that require such a file. # note: this assumes that you use #include header.moc in your files qt4_automoc(${qtproject_SRCS}) # create an executable file named qtproject from the source files in the variable qtproject_SRCS. add_executable(qtproject ${qtproject_SRCS}) TARGET_LINK_LIBRARIES(qtproject ${QT_LIBRARIES} ${QT_QTNETWORK_LIBRARIES} ${QT_QTTEST_LIBRARIES} ) Now when I build in vs2005 it says: 1-- Build started: Project: qtproject, Configuration: Release Win32 -- 1Linking... 1window.obj : error LNK2019: unresolved external symbol public: static struct QMetaObject const Window::staticMetaObject ([EMAIL PROTECTED]@@2UQMetaObject@@B) referenced in function public: static class QString __cdecl Window::tr(char const *,char const *) ([EMAIL PROTECTED]@@SA?AVQString@@[EMAIL PROTECTED]) 1window.obj : error LNK2001: unresolved external symbol public: virtual struct QMetaObject const * __thiscall Window::metaObject(void)const ([EMAIL PROTECTED]@@UBEPBUQMetaObject@@XZ) 1window.obj : error LNK2001: unresolved external symbol public: virtual void * __thiscall Window::qt_metacast(char const *) ([EMAIL PROTECTED]@@[EMAIL PROTECTED]) 1window.obj : error LNK2001: unresolved external symbol public: virtual int __thiscall Window::qt_metacall(enum QMetaObject::Call,int,void * *) ([EMAIL PROTECTED]@@[EMAIL PROTECTED]@@[EMAIL PROTECTED]) 1slidersgroup.obj : error LNK2001: unresolved external symbol public: virtual struct QMetaObject const * __thiscall SlidersGroup::metaObject(void)const ([EMAIL PROTECTED]@@UBEPBUQMetaObject@@XZ) 1slidersgroup.obj : error LNK2001: unresolved external symbol public: virtual void * __thiscall SlidersGroup::qt_metacast(char const *) ([EMAIL PROTECTED]@@[EMAIL PROTECTED]) 1slidersgroup.obj : error LNK2001: unresolved external symbol public: virtual int __thiscall SlidersGroup::qt_metacall(enum QMetaObject::Call,int,void * *) ([EMAIL PROTECTED]@@[EMAIL PROTECTED]@@[EMAIL PROTECTED]) 1Release\qtproject.exe : fatal error LNK1120: 7 unresolved externals 1Build log was saved at file://z:\temp2\qtproject.dir\Release\BuildLog.htm 1qtproject - 8 error(s), 0 warning(s) == Build: 0 succeeded, 1 failed, 1 up-to-date, 0 skipped == The BuildLog.htm says Build Log Build started: Project: qtproject, Configuration: Release|Win32 Command Lines Creating temporary file z:\temp2\qtproject.dir\Release\RSP0136204020.rsp with contents [ /OUT:Release\qtproject.exe /VERSION:0.0 /INCREMENTAL:NO /LIBPATH:c:\vtkBin\bin\Release /LIBPATH:c:\vtkBin\bin /LIBPATH:qtproject_srcs\Release /LIBPATH:qtproject_srcs /LIBPATH:optimized\Release /LIBPATH:optimized /LIBPATH:c:\QT\lib\QtGui4.lib\Release /LIBPATH:c:\QT\lib\QtGui4.lib /LIBPATH:debug\Release /LIBPATH:debug /LIBPATH:c:\QT\lib\QtGuid4.lib\Release /LIBPATH:c:\QT\lib\QtGuid4.lib /LIBPATH:Imm32\Release /LIBPATH:Imm32 /LIBPATH:Winmm\Release /LIBPATH:Winmm /LIBPATH:c:\QT\lib\QtCore4.lib\Release /LIBPATH:c:\QT\lib\QtCore4.lib /LIBPATH:c:\QT\lib\QtCored4.lib\Release