Important: Please read the Qt Code of Conduct -

Cmake 2.8.10 with Qt 5.0.1 under Win8 with VS2012: undefined external symbol

  • Hi!

    I have started fiddling with CMake aiming to serve as the makefile for a new project aiming linux and Windows platforms, involving many other libs, test modules, etc. Therefore it seems like the optimal choice. I wanted to create a comprehensive "tutorial" for some friends (and collegues) coming mainly from the Windows side of application development. Heavily commented makefiles with multiple interdependant projects, each showing one feature of CMake and getting more complex down the road.

    However with Qt involved I cannot even compile two simple projects, one targeting a shared library containing a simple QObject inherited class, and the other targeting an executable linking againts this library. Problem is that not even the library fails at linking with unresolved externals. I have built projects with both qmake before and the VS-plugin, but something is missing here. It seems as if the generated MOC files would not contain the required symbols or if cmake would not add them to the sources when building the target.

    (I have removed some comments to make post shorter)

    "Source code":


    "nmake output":

    Naturally problems arise when USE_QT5 is set. All help is greatly appreciated.

  • Hi,

    According to the "documentation":, only Qt4 is supported using AUTOMOC. Does the QT5_WRAP_CPP macro work?

Log in to reply