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)
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With