Migrating MFC to Qt
-
I'm trying to use the qtwinmigrate library to slowly migrate a large MFC app over to Qt. I'm following all the instructions but when I attempt to use the QtMfcApp:run command in my CWinApp I get a linker error. I'm sure all my paths and libs are correct and I added QT_QTWINMIGRATE_IMPORT to my preprocessor definitions, so I'm not sure why it's not working.
The error I get is…
4>XXX.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: static int __cdecl QMfcApp::run(class CWinApp *)" (_imp?run@QMfcApp@@SAHPAVCWinApp@@@Z) referenced in function "public: virtual int __thiscall CMyApp::Run(void)" (?Run@CMyApp@@UAEHXZ)
4>C:\Users\Dan\Documents\Source\Trunk\Debug\XXX.exe : fatal error LNK1120: 1 unresolved externalsI built the qtwinmigrate lib myself using the buildlib.pro project imported into VS 2019 using the Qt extension and built it as a Qt5 32bit DLL. (my MFC app is still 32bit)
I really can’t understand why it's not working. Everything seems to be in order.
Does anyone know what I could be doing wrong? Is there some special step I'm missing or some option in my MFC project I need to disable?
-
Hi,
Maybe a silly question but did you check that you built the library in 32bit as well ? Just in case you used a 64 bit Qt to build it.
-
Hi,
Maybe a silly question but did you check that you built the library in 32bit as well ? Just in case you used a 64 bit Qt to build it.
-
Strange... Did you check whether the symbols have been properly exported from the library ?
-
Strange... Did you check whether the symbols have been properly exported from the library ?
@SGaist That sent me down the right path. Apparently there is an #ifdef in the DLL that only exports those functions if you set the project to use MFC. I enabled MFC, rebuilt, and now my main project can link to the DLL.
Thanks for pointing me in the right direction. I never would have noticed that otherwise.