PDA

View Full Version : MFC->Qt Migration link error



LynneV
17th December 2009, 15:36
I need to migrate a very large, very old MFC application to Qt. I have been working with the (excellent) migration walkthrough (walkthrough doc (http://doc.trolltech.com/solutions/qtwinmigrate/winmigrate-walkthrough.html) - highly recommended for anyone trying something similar). I am trying to replicate Step 2 - merge MFC and QT event loops and instantiate QApplication. There is an "if defined" in qmfcapp.h for _AFXDLL that enables QTWINMIGRATE_WITHMFC. If I try to compile my application with this flag (it's for compiling a DLL, I'm trying to get a .lib), it errors with undefined functions in qtmfcapp. If I compile with the standard lib flag, it compiles, but won't link. I've tried setting the link libraries to everything under the sun - including compiling them with both/neither flags. The QT Migration Walkthrough Step 2 will compile AND link ... with output as application, dll or lib. Why? I can't find any way to set my application up to behave the same way as the example! Any assistance is much appreciated.

LynneV
25th December 2009, 22:13
I found at least one solution to this problem. If it helps anyone else...great! I manually defined __AFXDLL in a copy of qmfcapp.h. I set up the project inside the main solution that contains qmfcapp as multithreaded dll (C/C++ -> Code Generation). The main solution project needs to specify that the mfc libraries are loaded before CRT libraries, and you may have to add new libraries to ignore. I had to add mfc90d.lib / mfc90.lib and shift around the order of the existing libraries. I think it probably depends on how you have the old mfc project structured. Anyway, so far, it seems to work!