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. MOC Linking Errors from MSVC 2015

MOC Linking Errors from MSVC 2015

Scheduled Pinned Locked Moved Unsolved General and Desktop
2 Posts 2 Posters 2.0k 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.
  • O Offline
    O Offline
    ormris
    wrote on last edited by
    #1

    I've been using cmake to generate a MSVC project file. The entire project is written in C++ and makes use of signals and slots. I've enabled the "AUTOMOC" option cmake provides and it generates the necessary "moc_filename.cpp" files. I've included the generated files at the bottom of each implementation file for each class. The project compiles, but fails on the linking step with these types of errors:

    windows_gui_automoc.obj : error LNK2005: "private: static void __cdecl RemoteWindow::qt_static_metacall(class QObject *,enum QMetaObject::Call,int,void * *)" (?qt_static_metacall@RemoteWindow@@CAXPEAVQObject@@W4Call@QMetaObject@@HPEAPEAX@Z) already defined in moc_RemoteWindow.obj
    
    moc_ServerTab.obj : error LNK2001: unresolved external symbol "public: static struct QMetaObject const QWidget::staticMetaObject" (?staticMetaObject@QWidget@@2UQMetaObject@@B)
    
    TabDialog.obj : error LNK2001: unresolved external symbol "public: static struct QArrayData const * const QArrayData::shared_null" (?shared_null@QArrayData@@2QBU1@B)
    
    
    

    Any ideas as to what might be causing this?

    1 Reply Last reply
    0
    • jsulmJ Offline
      jsulmJ Offline
      jsulm
      Lifetime Qt Champion
      wrote on last edited by
      #2

      If you use automoc then you do not have to include the moc_.cpp files in your source files.
      The moc_
      .cpp files are compiled and linked automatically.

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0

      • Login

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