Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Link Error with Qt Win Migration Framework: unresolved symbol QWinWidget::staticMetaObject

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)

like image 223
Bret Kuhns Avatar asked May 29 '12 12:05

Bret Kuhns


1 Answers

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.

like image 199
Bret Kuhns Avatar answered Oct 17 '22 06:10

Bret Kuhns