Results 1 to 3 of 3

Thread: CMake :Undefined reference for a QObject class

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Apr 2010
    Posts
    8
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: CMake :Undefined reference for a QObject class

    Uping ? just in case of..

  2. #2
    Join Date
    Apr 2010
    Posts
    8
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: CMake :Undefined reference for a QObject class

    Well I finallly managed to get it thanks to http://qtnode.net/wiki/Qt4_with_cmake

    So this is a template of CMakeLists.txt for a classe called "MACLASSE" that would inherit from QObject (which was the problem because you then have to use QT_WRAPP_CPP
    Qt Code:
    1. cmake_minimum_required(VERSION 2.6)
    2. project(MACLASSE)
    3. set(LIBRARY_OUTPUT_PATH lib)
    4. find_package(Qt4 REQUIRED)
    5. INCLUDE(${QT_USE_FILE})
    6. include_directories(${QT_INCLUDES} ${CMAKE_CURRENT_BINARY_DIR} include)
    7.  
    8. SET (MACLASSE_SRCS src/MACLASSE.cpp)
    9. SET (MACLASSE_HEADERS include/MACLASSE.h)
    10.  
    11. MESSAGE( STATUS "sources: " ${MACLASSE_SRCS} )
    12. MESSAGE( STATUS "headers: " ${MACLASSE_HEADERS} )
    13.  
    14. qt4_wrap_cpp(MACLASSE_HEADERS_MOC ${MACLASSE_HEADERS}) #in there you put the headers and ONLY the headers
    15.  
    16. add_library(MACLASSE SHARED ${MACLASSE_SRCS} ${MACLASSE_HEADERS_MOC} )
    17. target_link_libraries(MACLASSE ${QT_LIBRARIES})
    To copy to clipboard, switch view to plain text mode 

Similar Threads

  1. undefined reference to `QUiLoader::QUiLoader(QObject*)'
    By ashukla in forum Qt Programming
    Replies: 7
    Last Post: 7th October 2011, 19:05
  2. QOBJECT and undefined reference to vtable errors
    By stargazer in forum Qt Programming
    Replies: 7
    Last Post: 25th April 2011, 06:29
  3. undefined reference to vtable in class
    By JeanC in forum Qt Programming
    Replies: 7
    Last Post: 26th February 2011, 11:23
  4. Replies: 1
    Last Post: 5th February 2011, 04:04
  5. undefined reference to QObject
    By hcerny in forum Qt Programming
    Replies: 2
    Last Post: 2nd May 2008, 17:55

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.