Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Migrating MFC to Qt
Qt 6.11 is out! See what's new in the release blog

Migrating MFC to Qt

Scheduled Pinned Locked Moved Solved General and Desktop
5 Posts 2 Posters 821 Views 2 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    Dan203
    wrote on last edited by
    #1

    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 externals

    I 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?

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      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.

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      D 1 Reply Last reply
      0
      • SGaistS SGaist

        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.

        D Offline
        D Offline
        Dan203
        wrote on last edited by
        #3

        @SGaist yes. I actually did build it as x64 first and the compiler gave me an error saying the DLL was for the wrong architecture. When I replaced it with the x86 version I started getting the above error.

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          Strange... Did you check whether the symbols have been properly exported from the library ?

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          D 1 Reply Last reply
          0
          • SGaistS SGaist

            Strange... Did you check whether the symbols have been properly exported from the library ?

            D Offline
            D Offline
            Dan203
            wrote on last edited by Dan203
            #5

            @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.

            1 Reply Last reply
            1

            • Login

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • Users
            • Groups
            • Search
            • Get Qt Extensions
            • Unsolved