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. Qt 6.8.0 upgrade: (Windows) no longer links to MFC ?

Qt 6.8.0 upgrade: (Windows) no longer links to MFC ?

Scheduled Pinned Locked Moved Solved General and Desktop
15 Posts 7 Posters 1.8k Views
  • 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
    davecotter
    wrote on 29 Jun 2024, 23:20 last edited by davecotter 7 Feb 2024, 02:47
    #1

    Using Qt6.7.1, with VS2019, in my project I was able to do this:

    #include <afxwin.h> // MFC core and standard components
    

    and the header would be "found" by the compiler, and the linker would link to MFC just fine.

    When i upgraded to Qt6.8.0, i had to upgrade to VS2022, and now it is not able to "find" the afxwin.h file, nor link to MFC.

    However, if i now add these lines to my .pro file:

    versionAtLeast(QT_VERSION, 6.8.0) {
    	DIR_ALTMFC	= C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.29.30133\atlmfc\
    
    	INCLUDEPATH	+= $${ALTMFC_PATH}include
    	LIBS		+= -L$${ALTMFC_PATH}lib\x64
    }
    

    It will now compile (ie: it FINDS the header file) but it still won't link, says:
    LINK1104: cannot open file 'mfc140ud.lib'

    note that the LIBS path definitely HAS that .lib file RIGHT THERE:

    Screenshot 2024-06-29 at 4.19.48 PM.png

    anyone know what's going on here?

    @SGaist

    C 1 Reply Last reply 2 Jul 2024, 05:41
    0
    • K Offline
      K Offline
      kkoehne
      Moderators
      wrote on 2 Jul 2024, 14:33 last edited by kkoehne 7 Feb 2024, 14:33
      #11

      @davecotter , please make sure that you have actually have MFC installed for Visual Studio 2022 , matching the exact MSVC toolchain/compiler verson. You can see int the Visual Studio Installer that there's a wealth of different packages, for the different MSVC compiler versions / architectures. For me, it's e.g. this package:

      10d76524-2efc-4e58-8330-473bf24278a7-grafik.png

      Director R&D, The Qt Company

      1 Reply Last reply
      3
      • H Online
        H Online
        hskoglund
        wrote on 29 Jun 2024, 23:50 last edited by
        #2

        Hi, try adding the lib filename with the -l switch, e.g.

        LIBS		+= -L$${ALTMFC_PATH}lib\x64 -lmfc140ud
        
        1 Reply Last reply
        0
        • D Offline
          D Offline
          davecotter
          wrote on 30 Jun 2024, 18:24 last edited by
          #3

          yes i should have said that that was the second thing i already tried.

          but why should i have to specify the paths and lib at all? i didn't have to do that when i was on VS2019 ??

          1 Reply Last reply
          0
          • C Offline
            C Offline
            Christian Ehrlicher
            Lifetime Qt Champion
            wrote on 30 Jun 2024, 18:38 last edited by Christian Ehrlicher
            #4

            Would you please specify what you mean with 'Qt7' and 'Qt8' - none of them is available anywhere. Do you mean Qt 6.7 and Qt6.8?
            Where does ALTMFC_PATH comes from?
            And don't ping specific users - at least for me this means I ignore the request directly...

            Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
            Visit the Qt Academy at https://academy.qt.io/catalog

            1 Reply Last reply
            1
            • D Offline
              D Offline
              davecotter
              wrote on 30 Jun 2024, 18:46 last edited by
              #5

              sorry, i mis-typed, what i mean is 6.7.1 vs. 6.8.0. I have corrected the OP

              1 Reply Last reply
              0
              • D Offline
                D Offline
                davecotter
                wrote on 2 Jul 2024, 02:56 last edited by
                #6

                @SGaist do you have any idea? or know who might?

                C 1 Reply Last reply 2 Jul 2024, 04:12
                0
                • D davecotter
                  2 Jul 2024, 02:56

                  @SGaist do you have any idea? or know who might?

                  C Offline
                  C Offline
                  Christian Ehrlicher
                  Lifetime Qt Champion
                  wrote on 2 Jul 2024, 04:12 last edited by
                  #7

                  @davecotter said in Qt 6.8.0 upgrade: (Windows) no longer links to MFC ?:

                  do you have any idea? or know who might?

                  I already told you that this is rude...

                  And you still did not answer my question...

                  Where does ALTMFC_PATH comes from?

                  Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
                  Visit the Qt Academy at https://academy.qt.io/catalog

                  1 Reply Last reply
                  0
                  • D davecotter
                    29 Jun 2024, 23:20

                    Using Qt6.7.1, with VS2019, in my project I was able to do this:

                    #include <afxwin.h> // MFC core and standard components
                    

                    and the header would be "found" by the compiler, and the linker would link to MFC just fine.

                    When i upgraded to Qt6.8.0, i had to upgrade to VS2022, and now it is not able to "find" the afxwin.h file, nor link to MFC.

                    However, if i now add these lines to my .pro file:

                    versionAtLeast(QT_VERSION, 6.8.0) {
                    	DIR_ALTMFC	= C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.29.30133\atlmfc\
                    
                    	INCLUDEPATH	+= $${ALTMFC_PATH}include
                    	LIBS		+= -L$${ALTMFC_PATH}lib\x64
                    }
                    

                    It will now compile (ie: it FINDS the header file) but it still won't link, says:
                    LINK1104: cannot open file 'mfc140ud.lib'

                    note that the LIBS path definitely HAS that .lib file RIGHT THERE:

                    Screenshot 2024-06-29 at 4.19.48 PM.png

                    anyone know what's going on here?

                    @SGaist

                    C Offline
                    C Offline
                    ChrisW67
                    wrote on 2 Jul 2024, 05:41 last edited by ChrisW67 7 Feb 2024, 05:42
                    #8

                    @davecotter

                    Any time I see spaces in a compiler/linker search path I immediately suggest that inadequate quoting could be part of the problem. See INCLUDEPATH and LIBS.

                    Does ALTMFC_PATH, wherever that comes from, end in a backslash?
                    Should ALTMFC_PATH actually be DIR_ALTMFC?
                    Is ALTMFC_PATH a typo for ATLMFC_PATH?
                    Do you get the same result using / rather than \ in the paths?

                    1 Reply Last reply
                    0
                    • A Offline
                      A Offline
                      Axel Spoerl
                      Moderators
                      wrote on 2 Jul 2024, 05:49 last edited by
                      #9

                      I can't reproduce the problem with a fresh Windows install and VS 2022.
                      I suspect that a wrong build tools version is installed.
                      The latest one is available here: https://aka.ms/vs/17/release/vs_BuildTools.exe.

                      Software Engineer
                      The Qt Company, Oslo

                      1 Reply Last reply
                      2
                      • C Offline
                        C Offline
                        cristian-adam
                        wrote on 2 Jul 2024, 10:44 last edited by
                        #10

                        I just had a look at my Visual Studio 2022 BuildTools installation, and found out that there is no more ATLMFC_PATH:

                        **********************************************************************
                        ** Visual Studio 2022 Developer Command Prompt v17.10.3
                        ** Copyright (c) 2022 Microsoft Corporation
                        **********************************************************************
                        [vcvarsall.bat] Environment initialized for: 'arm64'
                        
                        C:\
                        $ set | findstr ATLMFC_PATH
                        
                        C:\
                        $ set | findstr ATLMFC
                        EXTERNAL_INCLUDE=C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Tools\MSVC\14.40.33807\include;C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Tools\MSVC\14.40.33807\ATLMFC\include;C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Auxiliary\VS\include;C:\Program Files (x86)\Windows Kits\10\include\10.0.22621.0\ucrt;C:\Program Files (x86)\Windows Kits\10\\include\10.0.22621.0\\um;C:\Program Files (x86)\Windows Kits\10\\include\10.0.22621.0\\shared;C:\Program Files (x86)\Windows Kits\10\\include\10.0.22621.0\\winrt;C:\Program Files (x86)\Windows Kits\10\\include\10.0.22621.0\\cppwinrt
                        INCLUDE=C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Tools\MSVC\14.40.33807\include;C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Tools\MSVC\14.40.33807\ATLMFC\include;C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Auxiliary\VS\include;C:\Program Files (x86)\Windows Kits\10\include\10.0.22621.0\ucrt;C:\Program Files (x86)\Windows Kits\10\\include\10.0.22621.0\\um;C:\Program Files (x86)\Windows Kits\10\\include\10.0.22621.0\\shared;C:\Program Files (x86)\Windows Kits\10\\include\10.0.22621.0\\winrt;C:\Program Files (x86)\Windows Kits\10\\include\10.0.22621.0\\cppwinrt
                        LIB=C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Tools\MSVC\14.40.33807\ATLMFC\lib\ARM64;C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Tools\MSVC\14.40.33807\lib\ARM64;C:\Program Files (x86)\Windows Kits\10\lib\10.0.22621.0\ucrt\arm64;C:\Program Files (x86)\Windows Kits\10\\lib\10.0.22621.0\\um\arm64
                        LIBPATH=C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Tools\MSVC\14.40.33807\ATLMFC\lib\ARM64;C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Tools\MSVC\14.40.33807\lib\ARM64;C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Tools\MSVC\14.40.33807\lib\x86\store\references;C:\Program Files (x86)\Windows Kits\10\UnionMetadata\10.0.22621.0;C:\Program Files (x86)\Windows Kits\10\References\10.0.22621.0;C:\Windows\Microsoft.NET\Framework64\v4.0.30319
                        
                        C:\
                        $
                        

                        But the ATLMFC directory is part of the INCLUDE and LIB environment variables, which means that the compiler should find the files without any external configuration.

                        You might have to make sure that Qt Creator has the correct Visual C++ environment variables saved in the Compiler Toolchains.

                        Go to Edit > Preferences > Kits > Compilers and click on Remove All then Re-detect and then restart Qt Creator.

                        This will trigger Qt Creator to rerun all vcvarsall.bat scripts for Visual C++ and save its environment.

                        C 1 Reply Last reply 2 Jul 2024, 22:22
                        2
                        • K Offline
                          K Offline
                          kkoehne
                          Moderators
                          wrote on 2 Jul 2024, 14:33 last edited by kkoehne 7 Feb 2024, 14:33
                          #11

                          @davecotter , please make sure that you have actually have MFC installed for Visual Studio 2022 , matching the exact MSVC toolchain/compiler verson. You can see int the Visual Studio Installer that there's a wealth of different packages, for the different MSVC compiler versions / architectures. For me, it's e.g. this package:

                          10d76524-2efc-4e58-8330-473bf24278a7-grafik.png

                          Director R&D, The Qt Company

                          1 Reply Last reply
                          3
                          • C cristian-adam
                            2 Jul 2024, 10:44

                            I just had a look at my Visual Studio 2022 BuildTools installation, and found out that there is no more ATLMFC_PATH:

                            **********************************************************************
                            ** Visual Studio 2022 Developer Command Prompt v17.10.3
                            ** Copyright (c) 2022 Microsoft Corporation
                            **********************************************************************
                            [vcvarsall.bat] Environment initialized for: 'arm64'
                            
                            C:\
                            $ set | findstr ATLMFC_PATH
                            
                            C:\
                            $ set | findstr ATLMFC
                            EXTERNAL_INCLUDE=C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Tools\MSVC\14.40.33807\include;C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Tools\MSVC\14.40.33807\ATLMFC\include;C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Auxiliary\VS\include;C:\Program Files (x86)\Windows Kits\10\include\10.0.22621.0\ucrt;C:\Program Files (x86)\Windows Kits\10\\include\10.0.22621.0\\um;C:\Program Files (x86)\Windows Kits\10\\include\10.0.22621.0\\shared;C:\Program Files (x86)\Windows Kits\10\\include\10.0.22621.0\\winrt;C:\Program Files (x86)\Windows Kits\10\\include\10.0.22621.0\\cppwinrt
                            INCLUDE=C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Tools\MSVC\14.40.33807\include;C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Tools\MSVC\14.40.33807\ATLMFC\include;C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Auxiliary\VS\include;C:\Program Files (x86)\Windows Kits\10\include\10.0.22621.0\ucrt;C:\Program Files (x86)\Windows Kits\10\\include\10.0.22621.0\\um;C:\Program Files (x86)\Windows Kits\10\\include\10.0.22621.0\\shared;C:\Program Files (x86)\Windows Kits\10\\include\10.0.22621.0\\winrt;C:\Program Files (x86)\Windows Kits\10\\include\10.0.22621.0\\cppwinrt
                            LIB=C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Tools\MSVC\14.40.33807\ATLMFC\lib\ARM64;C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Tools\MSVC\14.40.33807\lib\ARM64;C:\Program Files (x86)\Windows Kits\10\lib\10.0.22621.0\ucrt\arm64;C:\Program Files (x86)\Windows Kits\10\\lib\10.0.22621.0\\um\arm64
                            LIBPATH=C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Tools\MSVC\14.40.33807\ATLMFC\lib\ARM64;C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Tools\MSVC\14.40.33807\lib\ARM64;C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Tools\MSVC\14.40.33807\lib\x86\store\references;C:\Program Files (x86)\Windows Kits\10\UnionMetadata\10.0.22621.0;C:\Program Files (x86)\Windows Kits\10\References\10.0.22621.0;C:\Windows\Microsoft.NET\Framework64\v4.0.30319
                            
                            C:\
                            $
                            

                            But the ATLMFC directory is part of the INCLUDE and LIB environment variables, which means that the compiler should find the files without any external configuration.

                            You might have to make sure that Qt Creator has the correct Visual C++ environment variables saved in the Compiler Toolchains.

                            Go to Edit > Preferences > Kits > Compilers and click on Remove All then Re-detect and then restart Qt Creator.

                            This will trigger Qt Creator to rerun all vcvarsall.bat scripts for Visual C++ and save its environment.

                            C Offline
                            C Offline
                            ChrisW67
                            wrote on 2 Jul 2024, 22:22 last edited by
                            #12

                            @cristian-adam said in Qt 6.8.0 upgrade: (Windows) no longer links to MFC ?:

                            I just had a look at my Visual Studio 2022 BuildTools installation, and found out that there is no more ATLMFC_PATH

                            So that answers one of my diagnostic questions:

                            Is ALTMFC_PATH a typo for ATLMFC_PATH?

                            Now we just need the OP to engage.

                            1 Reply Last reply
                            0
                            • D Offline
                              D Offline
                              davecotter
                              wrote on 7 Jul 2024, 00:26 last edited by davecotter 7 Jul 2024, 00:29
                              #13

                              My apologies for taking so long to respond, i've had very little time to work on this!

                              So, the original issue was solved by ensuring the correct version of MFC build tools was installed. With that, no need to specify path in .pro file, nor manually include header path or link to lib. It now compiles and links as expected.

                              thanks SO much for everyone's hints and help! It has really made a difference!

                              So, currently, what is NOT expected is this: when i attempt to run the app, it immediately crashes in mfc140u:

                              Screenshot 2024-07-06 at 5.23.45 PM.png

                              Screenshot 2024-07-06 at 5.23.51 PM.png

                              for this, i am 100% mystified. Do any of you amazing Gurus have any other clues?

                              -dave

                              (ps: sorry for tagging individuals, i hadn't realized it was frowned upon, and i had missed the warning!)

                              1 Reply Last reply
                              0
                              • H Online
                                H Online
                                hskoglund
                                wrote on 7 Jul 2024, 00:56 last edited by
                                #14

                                Hi, 0xc000026f usually means one or more of the dlls your Intel x64 app tries to load is for the ARM architecture (or the other way around), so maybe check what flavor of mfc140ud your path is set for.

                                1 Reply Last reply
                                0
                                • D Offline
                                  D Offline
                                  davecotter
                                  wrote on 7 Jul 2024, 01:21 last edited by davecotter 7 Jul 2024, 01:24
                                  #15

                                  hmm. how do i check what flavor? i'm definitely only building and debugging intel (although i am building it on an ARM computer)
                                  with VS2019, it all "just worked" so i'm not sure what changed when i went to VS2022 ?

                                  on mac (building on an ARM computer) i can specify in the QMake panel which "ABIs" i want: x86 and/or ARM, but on windows, there is no such UI switch. i'm not sure where else to look, or how to determine which is being selected when linking?

                                  1 Reply Last reply
                                  0
                                  • D davecotter has marked this topic as solved on 8 Jul 2024, 18:47
                                  • D davecotter referenced this topic on 8 Jul 2024, 19:04

                                  8/15

                                  2 Jul 2024, 05:41

                                  • Login

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