Link Error with Qt Win Migration Framework: unresolved symbol QWinWidget::staticMetaObject
qt, qt-mfc-migration
Solution
According to this forum post, a preprocessor definition must be added to the MFC project that's using the Qt Win Migration framework as a library. Simply add
`QT_QTWINMIGRATE_IMPORT`
to the project settings under `Properties -> C/C++ -> Preprocessor -> Preprocessor Definitions`.
For a more in-depth explanation into why this is necessary, see this blog post.
Problem
I'm trying to set up the Qt Win Migration framework to use Qt in an existing MFC based application. I want to use the framework as a library, so I ran `qmake` on the `qtwinmigrate/buildlib/buildlib.pro` file to create a Visual Studio vcxproj project file. I built the framework as a dll/lib and put the headers in a common include directory. In my MFC project, I added the Qt migration framework's lib as a dependency, included the headers where appropriate and added the code to test the framework. Everything compiles fine, but then I get a linker error: error LNK2001: unresolved external symbol "public: static struct QMetaObject const QWinWidget::staticMetaObject" (?staticMetaObject@QWinWidget@@2UQMetaObject@@B)