Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Link error: QMetaObject with cmake when compiling VTK example

Link error: QMetaObject with cmake when compiling VTK example

Scheduled Pinned Locked Moved Solved General and Desktop
qt5vtkcmakeqmetaobjectlink error
2 Posts 1 Posters 1.7k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • G Offline
    G Offline
    gde23
    wrote on 7 Sept 2017, 09:35 last edited by
    #1

    Hello,
    i am trying to compile a Qt (Qt5.8) / VTK (8.0.0) example from here.

    I am using cmake and i have
    set(CMAKE_AUTOMOC ON)

    However i get a linking error with QMetaObject.

    Error:

    RenderWindowUIMultipleInheritance.cxx.obj:-1: error: LNK2001: unresolved external symbol "public: static struct QMetaObject const QVTKWidget::staticMetaObject" (?staticMetaObject@QVTKWidget@@2UQMetaObject@@B)
    RenderWindowUIMultipleInheritanceDriver.cxx.obj:-1: error: LNK2001: unresolved external symbol "public: static struct QMetaObject const QVTKWidget::staticMetaObject" (?staticMetaObject@QVTKWidget@@2UQMetaObject@@B)
    moc_compilation.cpp.obj:-1: error: LNK2001: unresolved external symbol "public: static struct QMetaObject const QVTKWidget::staticMetaObject" (?staticMetaObject@QVTKWidget@@2UQMetaObject@@B)
    

    Here is the CMakeLists.txt i use for the project

    cmake_minimum_required(VERSION 2.8)
    
    if(POLICY CMP0020)
      cmake_policy(SET CMP0020 NEW)
    endif()
    
    PROJECT(RenderWindowUIMultipleInheritance)
    
    find_package(VTK REQUIRED)
    include(${VTK_USE_FILE})
    
    # Instruct CMake to run moc automatically when needed.
    set(CMAKE_AUTOMOC ON)
    find_package(Qt5Widgets REQUIRED QUIET)
    
    include_directories(${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR})
    
    file(GLOB UI_FILES *.ui)
    file(GLOB QT_WRAP *.h)
    file(GLOB CXX_FILES *.cxx)
    
    qt5_wrap_ui(UISrcs ${UI_FILES} )
    # CMAKE_AUTOMOC in ON so the MOC headers will be automatically wrapped.
    add_executable(RenderWindowUIMultipleInheritance MACOSX_BUNDLE
    ${CXX_FILES} ${UISrcs} ${QT_WRAP})
    qt5_use_modules(RenderWindowUIMultipleInheritance Core Gui)
    target_link_libraries(RenderWindowUIMultipleInheritance ${VTK_LIBRARIES})
    

    any ideas where the problem is?

    1 Reply Last reply
    0
    • G Offline
      G Offline
      gde23
      wrote on 7 Sept 2017, 11:31 last edited by
      #2

      Found the error myself.
      In the include dir there still was the file vtkGUISupportQtModule.h from the vtk-build included which defines

      VTKGUISUPPORTQT_EXPORT __declspec(dllexport)
      

      now its working

      1 Reply Last reply
      0

      1/2

      7 Sept 2017, 09:35

      • Login

      • Login or register to search.
      1 out of 2
      • First post
        1/2
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved